| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 | // Licensed to the .NET Foundation under one or more agreements.// The .NET Foundation licenses this file to you under the MIT License.// See the LICENSE file in the project root for more information. using System;using System.Reactive.Linq;using Microsoft.Reactive.Testing;using Microsoft.VisualStudio.TestTools.UnitTesting;namespace ReactiveTests.Tests{    [TestClass]    public class IsEmptyTest : ReactiveTest    {        [TestMethod]        public void IsEmpty_ArgumentChecking()        {            ReactiveAssert.Throws<ArgumentNullException>(() => Observable.IsEmpty(default(IObservable<int>)));        }        [TestMethod]        public void IsEmpty_Empty()        {            var scheduler = new TestScheduler();            var xs = scheduler.CreateHotObservable(                OnNext(150, 1),                OnCompleted<int>(250)            );            var res = scheduler.Start(() =>                xs.IsEmpty()            );            res.Messages.AssertEqual(                OnNext(250, true),                OnCompleted<bool>(250)            );            xs.Subscriptions.AssertEqual(                Subscribe(200, 250)            );        }        [TestMethod]        public void IsEmpty_Return()        {            var scheduler = new TestScheduler();            var xs = scheduler.CreateHotObservable(                OnNext(150, 1),                OnNext(210, 2),                OnCompleted<int>(250)            );            var res = scheduler.Start(() =>                xs.IsEmpty()            );            res.Messages.AssertEqual(                OnNext(210, false),                OnCompleted<bool>(210)            );            xs.Subscriptions.AssertEqual(                Subscribe(200, 210)            );        }        [TestMethod]        public void IsEmpty_Throw()        {            var ex = new Exception();            var scheduler = new TestScheduler();            var xs = scheduler.CreateHotObservable(                OnNext(150, 1),                OnError<int>(210, ex)            );            var res = scheduler.Start(() =>                xs.IsEmpty()            );            res.Messages.AssertEqual(                OnError<bool>(210, ex)            );            xs.Subscriptions.AssertEqual(                Subscribe(200, 210)            );        }        [TestMethod]        public void IsEmpty_Never()        {            var ex = new Exception();            var scheduler = new TestScheduler();            var xs = scheduler.CreateHotObservable(                OnNext(150, 1)            );            var res = scheduler.Start(() =>                xs.IsEmpty()            );            res.Messages.AssertEqual(            );            xs.Subscriptions.AssertEqual(                Subscribe(200, 1000)            );        }    }}
 |