public async Task IF_location_throws_exception_SHOULD_error()
            {
                //Arrange
                var result1 = new TaskCompletionSource <IGpsLocation>();
                var result2 = new TaskCompletionSource <Exception>();

                //Act
                var disposable = Sut.Connect(_requirements)
                                 .Subscribe(next =>
                {
                    result1.SetResult(next);
                }, ex =>
                {
                    result2.SetResult(ex);
                });

                //Assert
                MockProxy.Where_GetCurrentLocationAsync_returns(new Location(0, 2));
                _testScheduler.AdvanceBy(1000);
                var first = await result1.Task;

                Assert.That(first.Latitude, Is.EqualTo(0));

                MockProxy.Where_GetCurrentLocationAsync_throws(new Exception("oops"));
                _testScheduler.AdvanceBy(1000);
                var second = await result2.Task;

                Assert.That(second.ToError(), Is.EqualTo(GeolocationErrors.Unexpected));
                Assert.That(second.InnerException.Message, Is.EqualTo("oops"));
                MockAnalyticsService.VerifyLogException <Exception>("oops");
                disposable.Dispose();
            }
Пример #2
0
        public void IF_exception_is_thrown_SHOULD_log()
        {
            //Act
            Sut.HandleForegroundNotification("Won't parse");

            //Assert
            MockAnalyticsService.VerifyLogException <Exception>("Unexpected character encountered while parsing value: W. Path '', line 0, position 0.");
        }
        public void IF_exception_is_thrown_SHOULD_log()
        {
            //Act
            Sut.HandleForegroundNotification(null);

            //Assert
            MockAnalyticsService.VerifyLogException <ArgumentNullException>();
        }
Пример #4
0
        public void IF_exception_is_thrown_SHOULD_log()
        {
            //Act
            Sut.HandleForegroundNotification("Won't parse");

            //Assert
            MockAnalyticsService.VerifyLogException <ArgumentException>("Did not find expected beginning text of '<toast launch=\"'");
        }
        public async Task SHOULD_log_exception()
        {
            //Arrange
            var exception = new Exception("failio");

            //Act
            await Sut.HandleExceptionAsync(this, exception);

            //Assert
            MockAnalyticsService.VerifyLogException(exception);
        }
        public async Task IF_API_call_throws_SHOULD_return_Error()
        {
            //Arrange
            MockProxy.Where_GetLocationsFromAddressAsync_throws(new Exception("oops"));

            //Act
            var result = await Sut.FromAddressAsync(_addressString);

            //Assert
            Assert.That(result.IsError(GeolocationErrors.GpsLookupFailed));
            MockAnalyticsService.VerifyLogException <Exception>("oops");
        }
Пример #7
0
        public async Task IF_exception_is_thrown_SHOULD_log()
        {
            //Arrange
            MockPushNotificationTapHandler.Mock.Setup(x => x.HandleTapAsync(It.IsAny <IPushNotification>()))
            .ThrowsAsync(new ArgumentException("oh no you don't"));

            //Act
            await Sut.HandleNotificationTappedAsync(AndroidIntentProperties);

            //Assert
            MockAnalyticsService.VerifyLogException <ArgumentException>("oh no you don't");
        }
Пример #8
0
        public void IF_exception_is_thrown_SHOULD_log()
        {
            //Arrange
            MockPushNotificationTapHandler.Mock.Setup(x => x.HandleTapAsync(It.IsAny <IPushNotification>()))
            .ThrowsAsync(new ArgumentException("oh no you don't"));

            //Test
            Sut.HandleAppLaunchingAsync(Arguments);

            //Assert
            MockAnalyticsService.VerifyLogException <ArgumentException>("oh no you don't");
        }
        public async Task IF_command_handler_throws_SHOULD_log_exception_and_rethrow()
        {
            //Arrange
            _mockTestCommandHandler.Where_HandleAsync_throws(new Exception("Oops"));

            //Act
            Assert.ThrowsAsync <Exception>(async() =>
                                           await Sut.HandleAsync <TestServerPayload, TestCommand>(MockResolverContext.Object, CancellationToken.None));

            //Asserrt
            MockAnalyticsService.VerifyLogException <Exception>("Oops");
        }
Пример #10
0
        public async Task IF_command_handler_throws_SHOULD_log_exception_and_rethrow()
        {
            //Arrange
            MockCommandHandler.Mock.Setup(x => x.HandleAsync(It.IsAny <TestCommand>(), It.IsAny <IAuthenticatedUser>(), It.IsAny <CancellationToken>()))
            .ThrowsAsync(new Exception("Oops"));

            //Act
            Assert.ThrowsAsync <Exception>(async() =>
                                           await Sut.HandleAsync <TestCommand>(MockResolverContext.Object, CancellationToken.None));

            //Asserrt
            MockAnalyticsService.VerifyLogException <Exception>("Oops");
        }
            public async Task IF_current_location_throws_SHOULD_error()
            {
                //Arrange
                MockProxy.Where_GetCurrentLocationAsync_throws(new Exception("oops"));

                //Act
                Sut.Connect(_requirements).Subscribe(next => { }, ex => { ExceptionTaskCompletionSource.SetResult(ex); });
                var exception = await ExceptionTaskCompletionSource.Task;

                //Assert
                Assert.That(exception.ToError(), Is.EqualTo(GeolocationErrors.Unexpected));
                Assert.That(exception.InnerException.Message, Is.EqualTo("oops"));
                MockAnalyticsService.VerifyLogException <Exception>("oops");
            }