Beispiel #1
0
        public async Task Count0()
        {
            string result  = "";
            var    subject = new UnicastAsyncSubject <int>();

            var s = subject.SubscribeAsync(i => result += i, onCompleted: () => result += "C");

            await subject.OnSubscribeAsync(Disposable.Empty);

            await subject.OnCompletedAsync();

            await subject.OnFinallyAsync();

            await s;

            result
            .Should().Be("C");
        }
Beispiel #2
0
        public async Task Throwing()
        {
            string result  = "";
            var    subject = new UnicastAsyncSubject <int>();

            var s = subject.SubscribeAsync(i => result += i, onCompleted: () => result += "C", onError: ex => result += "E");

            await subject.OnSubscribeAsync(Disposable.Empty);

            await subject.OnNextAsync(0);

            await subject.OnErrorAsync(new Exception());

            await subject.OnFinallyAsync();

            await s;

            result
            .Should().Be("0E");
        }
Beispiel #3
0
        public async Task SubscriptionTask()
        {
            string result  = "";
            var    subject = new UnicastAsyncSubject <int>();

            var s = subject.SubscribeAsync(i => result += i, onCompleted: () => result += "C");

            await subject.OnSubscribeAsync(Disposable.Empty);

            await subject.OnNextAsync(0);

            await subject.OnCompletedAsync();

            s.IsCompleted
            .Should().BeFalse();

            await subject.OnFinallyAsync();

            await s;
        }
Beispiel #4
0
        public async Task LateSubscribe()
        {
            string result  = "";
            var    subject = new UnicastAsyncSubject <int>();


            var t = subject.OnSubscribeAsync(Disposable.Empty);
            var s = subject.SubscribeAsync(i => result += i, onCompleted: () => result += "C", onError: ex => result += "E");

            await t;
            await subject.OnNextAsync(0);

            await subject.OnCompletedAsync();

            await subject.OnFinallyAsync();

            await s;

            result
            .Should().Be("0C");
        }
Beispiel #5
0
        public async Task Count10()
        {
            string result  = "";
            var    subject = new UnicastAsyncSubject <int>();

            var s = subject.SubscribeAsync(i => result += i, onCompleted: () => result += "C");

            await subject.OnSubscribeAsync(Disposable.Empty);

            await subject.OnNextAsync(0);

            await subject.OnNextAsync(1);

            await subject.OnNextAsync(2);

            await subject.OnNextAsync(3);

            await subject.OnNextAsync(4);

            await subject.OnNextAsync(5);

            await subject.OnNextAsync(6);

            await subject.OnNextAsync(7);

            await subject.OnNextAsync(8);

            await subject.OnNextAsync(9);

            await subject.OnCompletedAsync();

            await subject.OnFinallyAsync();

            await s;

            result
            .Should().Be("0123456789C");
        }