Beispiel #1
0
        public void ObservableOnCompletedTest()
        {
            TestAsyncCommand command = new TestAsyncCommand();

            bool wasCompleted = false;

            command.GetExecutionObservable().Subscribe(_ => { }, () => wasCompleted = true);

            wasCompleted.Should().BeTrue();
        }
Beispiel #2
0
        public void ObservableOnBadRequestExceptionTest()
        {
            TestAsyncCommand command = new TestAsyncCommand();

            command.ExceptionToThrow = new BadRequestException("test", "test error");
            IObservable <string> observable = command.GetExecutionObservable();

            Exception actualException = null;

            observable.Subscribe(_ => { }, ex => actualException = ex);

            actualException.Should().NotBeNull();
            actualException.Should().BeOfType <BadRequestException>();
        }
Beispiel #3
0
        public void ObservableOnNextTest()
        {
            TestAsyncCommand command          = new TestAsyncCommand();
            const string     expectedResponse = "test";

            command.Response = expectedResponse;
            IObservable <string> observable = command.GetExecutionObservable();

            string actualResponse = null;

            observable.Subscribe(response => actualResponse = response);

            actualResponse.ShouldBeEquivalentTo(expectedResponse);
        }
Beispiel #4
0
        public void ObservableOnUnhandledCommandExceptionTest()
        {
            TestAsyncCommand command = new TestAsyncCommand();

            command.ExceptionToThrow = new InvalidOperationException("test error");
            IObservable <string> observable = command.GetExecutionObservable();

            Exception actualException = null;

            observable.Subscribe(_ => { }, ex => actualException = ex);

            actualException.Should().NotBeNull();
            actualException.Should().BeOfType <UnhandledCommandException>();
            actualException.InnerException.Should().BeOfType <InvalidOperationException>();
        }