Esempio n. 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");
        }
Esempio n. 2
0
        public async Task Empty()
        {
            var value = await AsyncObservable.Empty <int>().AllAsync(i => false);

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

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

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

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

            func
            .Should().ThrowExactly <InvalidOperationException>();
        }
Esempio n. 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");
        }
Esempio n. 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");
        }
Esempio n. 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");
        }
Esempio n. 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");
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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");
        }
Esempio n. 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");
        }
Esempio n. 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");
        }
Esempio n. 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>();
        }
Esempio n. 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>();
        }