예제 #1
0
        public void Throw()
        {
            Func <Task <bool> > func = async() => await AsyncObservable.Throw <int>(new NotImplementedException()).AllAsync(i => i < 0);

            func
            .Should().ThrowExactly <NotImplementedException>();
        }
예제 #2
0
        public void ThrowWithPredicate()
        {
            Func <Task <bool> > func = async() => await AsyncObservable.Throw <int>(new NotImplementedException()).AnyAsync(v => false);

            func
            .Should().ThrowExactly <NotImplementedException>();
        }
예제 #3
0
        public async Task Throw1()
        {
            string result = "";

            await AsyncObservable.Throw <int>(new Exception())
            .SubscribeAsync(i => result += i, ex => result += "E", () => result += "C");

            result
            .Should().Be("E");
        }
        public async Task Throw()
        {
            string result = "";

            await AsyncObservable.Throw <int>(new NotImplementedException())
            .DistinctUntilChanged()
            .SubscribeAsync(i => result += i, onError: ex => result += "E", onCompleted: () => result += "C");

            result
            .Should().Be("E");
        }
예제 #5
0
        public async Task Finally5()
        {
            string result = "";

            await AsyncObservable.Throw <int>(new Exception())
            .Finally(() => result       += "1")
            .Finally(() => result       += "2")
            .SubscribeAsync(i => result += "N", ex => result += "E", () => result += "C");

            result
            .Should().Be("12E");
        }
예제 #6
0
        public async Task Params3Error2()
        {
            string result = "";

            var obs1 = AsyncObservable.Range(0, 3).Finally(() => result += ",");
            var obs2 = AsyncObservable.Throw <int>(new Exception());
            var obs3 = AsyncObservable.Throw <int>(new Exception());

            await AsyncObservable
            .Concat(obs1, obs2, obs3)
            .Finally(() => result       += "F")
            .SubscribeAsync(i => result += i, ex => result += "E", () => result += "C");

            result
            .Should().Be("012,EF");
        }
예제 #7
0
        public async Task ThrowingItem()
        {
            string result = "";

            var seq = new[]
            {
                AsyncObservable.Range(0, 3).Finally(() => result += ","),
                AsyncObservable.Throw <int>(new Exception()),
                AsyncObservable.Range(5, 3).Finally(() => result += ",")
            }.ToAsyncObservable();

            await seq
            .LazyConcat()
            .Finally(() => result += "F")
            .SubscribeAsync(i => result += i, ex => result += "E", () => result += "C");

            result
            .Should().Be("012,FE");
        }
예제 #8
0
        public async Task Enum3Error2()
        {
            string result = "";

            var obs = new[]
            {
                AsyncObservable.Range(0, 3).Finally(() => result += ","),
                AsyncObservable.Throw <int>(new Exception()),
                AsyncObservable.Throw <int>(new Exception())
            };

            await obs
            .Concat()
            .Finally(() => result += "F")
            .SubscribeAsync(i => result += i, ex => result += "E", () => result += "C");

            result
            .Should().Be("012,EF");
        }