예제 #1
0
        public async Task Finally6()
        {
            string result   = "";
            bool   rethrown = false;

            try
            {
                await AsyncObservable.Empty <int>()
                .Finally(() =>
                {
                    result += "1";
                    throw new Exception();
                })
                .Finally(() =>
                {
                    result += "2";
                    throw new Exception();
                })
                .SubscribeAsync();
            }
            catch
            {
                rethrown = true;
            }

            rethrown
            .Should().Be(true);
            result
            .Should().Be("12");
        }
예제 #2
0
        public async Task Empty()
        {
            var value = await AsyncObservable.Empty <int>().AllAsync(i => false);

            value
            .Should().Be(true);
        }
예제 #3
0
        public async Task Empty()
        {
            var value = await AsyncObservable.Empty <int>().ToListAsync();

            value
            .Should().HaveCount(0);
        }
예제 #4
0
        public async Task Empty()
        {
            var value = await AsyncObservable.Empty <int>().AnyAsync();

            value
            .Should().Be(false);
        }
예제 #5
0
        public async Task EmptyWithPredicate()
        {
            var value = await AsyncObservable.Empty <int>().AnyAsync(i => i > 4);

            value
            .Should().Be(false);
        }
예제 #6
0
        public void Count0()
        {
            Func <Task <int> > func = async() => await AsyncObservable.Empty <int>().FirstAsync();

            func
            .Should().ThrowExactly <InvalidOperationException>();
        }
예제 #7
0
        public async Task Empty1()
        {
            string result = "";

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

            result
            .Should().Be("C");
        }
예제 #8
0
        public async Task Int_Intermediate_Empty()
        {
            string result = "";

            await AsyncObservable.Empty <int>()
            .Max(intermediateResults: true)
            .SubscribeAsync(i => result += i, onError: ex => result += "E", onCompleted: () => result += "C");

            result
            .Should().Be("E");
        }
예제 #9
0
        public async Task Double_Empty()
        {
            var result = "";

            await AsyncObservable.Empty <double>()
            .Max()
            .SubscribeAsync(i => result += i, onError: ex => result += "E", onCompleted: () => result += "C");

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

            await AsyncObservable.Empty <long>()
            .Max()
            .SubscribeAsync(i => result += i, onError: ex => result += "E", onCompleted: () => result += "C");

            result
            .Should().Be("E");
        }
예제 #11
0
        public async Task Double_Intermediate_Empty()
        {
            double result = Double.NaN;

            await AsyncObservable.Empty <double>()
            .Sum(intermediateResults: true)
            .SubscribeAsync(i => result = i);

            result
            .Should().Be(Double.NaN);
        }
예제 #12
0
        public async Task Double_Empty()
        {
            double result = 0.0;

            await AsyncObservable.Empty <double>()
            .Sum()
            .SubscribeAsync(i => result = i);

            result
            .Should().Be(0.0);
        }
예제 #13
0
        public async Task Int_Empty()
        {
            string result = "";

            await AsyncObservable.Empty <int>()
            .Sum()
            .SubscribeAsync(i => result += i, onCompleted: () => result += "C");

            result
            .Should().Be("0C");
        }
        public async Task Empty()
        {
            string result = "";

            await AsyncObservable.Empty <int>()
            .DistinctUntilChanged()
            .SubscribeAsync(i => result += i, onCompleted: () => result += "C");

            result
            .Should().Be("C");
        }
예제 #15
0
        public async Task Int_Nullable_Empty()
        {
            string result = "";

            await AsyncObservable.Empty <int?>()
            .Max()
            .SubscribeAsync(i => result += i == null ? "null" : i.ToString(), onError: ex => result += "E", onCompleted: () => result += "C");

            result
            .Should().Be("nullC");
        }
예제 #16
0
        public async Task Finally3()
        {
            string result = "";

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

            result
            .Should().Be("12C");
        }
예제 #17
0
        public void ArgumentExceptions()
        {
            Func <Task> action;

            action = async() => await default(IAsyncObservable <int>).AllAsync(i => true);
            action
            .Should().Throw <ArgumentNullException>();

            action = async() => await AsyncObservable.Empty <int>().AllAsync(null);

            action
            .Should().Throw <ArgumentNullException>();
        }
예제 #18
0
        public void ArgumentExceptions()
        {
            Func <IDisposable> funcR = null;
            Func <IDisposable, IAsyncObservable <int> > funcO = null;

            Action action;

            action = () => AsyncObservable.Using(funcR, _ => AsyncObservable.Empty <int>());
            action
            .Should().Throw <ArgumentNullException>();

            action = () => AsyncObservable.Using(() => new BooleanDisposable(), funcO);
            action
            .Should().Throw <ArgumentNullException>();

            action = () => AsyncObservable.Using(funcR, funcO);
            action
            .Should().Throw <ArgumentNullException>();
        }