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(); }
public async Task IF_location_returned_is_invalid_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_returns(new Location(0, 2222, DateTimeOffset.Now)); _testScheduler.AdvanceBy(1000); var second = await result2.Task; Assert.That(second.ToError(), Is.EqualTo(GeolocationErrors.InvalidLongitude)); MockAnalyticsService.VerifyTrace(GeolocationErrors.InvalidLongitude.ToString(), LogSeverity.Error); disposable.Dispose(); }
public async Task SHOULD_trace_success() { //Act await Sut.DeregisterUserDeviceAsync("myUserId", "myDeviceId", MockNotificationHub.Object); //Assert MockAnalyticsService.VerifyTrace("Templates cleared for push notifications registration"); }
public void IF_exception_is_thrown_SHOULD_log() { //Act Sut.HandleForegroundNotification(null); //Assert MockAnalyticsService.VerifyLogException <ArgumentNullException>(); }
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 async Task SHOULD_trace() { //Act await Sut.UpdateDeviceRegistrationAsync(_dataOnlyDeviceRegistration, MockNotificationHub.Object); //Assert MockAnalyticsService.VerifyTrace("Push notification registration updated"); }
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() { //Act Sut.NotifyAppStarting(); await Task.Delay(10); //Assert MockAnalyticsService.VerifyTrace("App Starting. Notifying handlers: 2"); }
public async Task SHOULD_track_operation() { //Act var result = await Sut.UpdateDeviceRegistrationAsync(_dataOnlyDeviceRegistration, MockNotificationHub.Object); //Assert MockAnalyticsService.VerifyTrace("Register device for push notifications"); MockAnalyticsService.VerifyTraceProperty(nameof(DeviceRegistration), _dataOnlyDeviceRegistration); }
public async Task SHOULD_extract_command_and_log_with_analytics() { //Act await Sut.HandleAsync <TestCommand>(MockResolverContext.Object, CancellationToken.None); //Assert MockAnalyticsService.VerifyTrace("TestCommand received"); MockAnalyticsService.VerifyTraceProperty("TestCommand", _command); }
public async Task SHOULD_trace_success() { //Act await Sut.FromAddressAsync(_addressString); //Assert MockAnalyticsService.VerifyTrace("GPS cooridnates found from address"); MockAnalyticsService.VerifyTraceProperty("Address", _addressString); }
public async Task WHEN_saving_new_handle_SHOULD_log_analytics() { //Act await Sut.UpdatePushNotificationServiceHandleAsync("new Handle"); //Assert MockAnalyticsService.VerifyTrace("PnsHandle saved", LogSeverity.Information); MockAnalyticsService.VerifyTraceProperty("PnsHandle", "new Handle"); }
public async Task SHOULD_load_and_return_handle_from_secure_storage() { //Act var result = await Sut.GetPushNotificationServiceHandleAsync(); //Assert Assert.AreEqual("stored handle", result); MockAnalyticsService.VerifyTrace("PnsHandle loaded"); MockAnalyticsService.VerifyTraceProperty("PnsHandle", "stored handle"); }
public async Task SHOULD_track_operation() { //Act await Sut.SendNotificationToTargetAsync(_pushNotification, _target, MockNotificationHub.Object); //Assert MockAnalyticsService.VerifyTrace("Send push notification to device"); MockAnalyticsService.VerifyTraceProperty(nameof(PushNotification), _pushNotification); MockAnalyticsService.VerifyTraceProperty(nameof(DeviceTarget), _target); }
public async Task SHOULD_track_operation() { //Act await Sut.LoadRegistrationForUserDeviceAsync("myUserId", "myDeviceId", MockNotificationHub.Object); //Assert MockAnalyticsService.VerifyTrace("Load push notification registration for user device"); MockAnalyticsService.VerifyTraceProperty("UserId", "myUserId"); MockAnalyticsService.VerifyTraceProperty("DeviceIdentifier", "myDeviceId"); }
public async Task SHOULD_track_operation() { //Act await Sut.SendNotificationToUserAsync(_notification, _userId, MockNotificationHub.Object); //Assert MockAnalyticsService.VerifyTrace("Sending push notification to user"); MockAnalyticsService.VerifyTraceProperty(nameof(IPushNotification), _notification); MockAnalyticsService.VerifyTraceProperty("UserId", _userId); }
public async Task SHOULD_trace_success() { //Act await Sut.ToAddressAsync(_gpsLocation); //Assert MockAnalyticsService.VerifyTrace("Address found from GPS coordinates"); MockAnalyticsService.VerifyTraceProperty("Address", "feature name, sub thoroughfare thoroughfare, sub locality, sub admin area, locality, admin area, postal code, country name"); MockAnalyticsService.VerifyTraceProperty(nameof(GpsLocation), _gpsLocation); }
public async Task SHOULD_extract_command_and_log_with_analytics() { //Act await Sut.HandleAsync <TestServerPayload, TestCommand>(MockResolverContext.Object, CancellationToken.None); //Assert MockCommandHandler.Mock.Verify(x => x.HandleAsync(It.Is <TestCommand>(y => y.Name == "Piet"), It.IsAny <CancellationToken>())); MockAnalyticsService.VerifyTrace("TestCommand received"); MockAnalyticsService.VerifyTraceProperty("TestCommand", _command); }
public override void Setup() { base.Setup(); MockGraphqlClientConfig.With(x => x.GraphqlEndpoint, "http://www.google.com"); MockAnalyticsService.With(x => x.AnalyticsOperationHeaders, new Dictionary <string, string>()); MockAuthenticatedAccessToken.With(x => x.AdditionalHeaders, new Dictionary <string, string>()); AddService(x => MockGraphqlClientConfig.Object); AddService(x => MockAuthenticatedAccessToken.Object); }
public async Task SHOULD_log_exception() { //Arrange var exception = new Exception("failio"); //Act await Sut.HandleExceptionAsync(this, exception); //Assert MockAnalyticsService.VerifyLogException(exception); }
public void SHOULD_log_operation_and_trace_content() { //Test Sut.HandleAppLaunchingAsync(Arguments); //Assert MockAnalyticsService.VerifyStartTrace("Push Notification Tapped"); MockAnalyticsService.VerifyTrace("Extracting push notification"); MockAnalyticsService.VerifyTraceProperty("Raw Notification", Arguments); MockAnalyticsService.VerifyTrace("Notification processed"); }
public async Task SHOULD_log_operation_and_trace_content() { //Test await Sut.HandleNotificationTappedAsync(AndroidIntentProperties); //Assert MockAnalyticsService.VerifyStartTrace("Push Notification Tapped"); MockAnalyticsService.VerifyTrace("Extracting push notification"); MockAnalyticsService.VerifyTraceProperty("Raw Notification", AndroidIntentProperties); MockAnalyticsService.VerifyTrace("Notification processed"); }
public void SHOULD_log_operation_and_trace_content() { //Test Sut.HandleForegroundNotification(IosNotification); //Assert MockAnalyticsService.VerifyStartTrace("Foreground Push Notification"); MockAnalyticsService.VerifyTrace("Extracting push notification"); MockAnalyticsService.VerifyTraceProperty("Raw Notification", IosNotification); MockAnalyticsService.VerifyTrace("Notification processed"); }
public async Task SHOULD_Trace_connection() { //Arrange _requirements = new GeolocationRequirements(TimeSpan.FromMinutes(1), LocationAccuracy.Low); //Act Sut.Connect(_requirements).Subscribe(next => { }); //Assert MockAnalyticsService.VerifyTrace("New GpsLocation connection requested with accuracy Low and interval 00:01:00"); }
public async Task IF_last_known_location_is_null_SHOULD_trace() { //Arrange MockProxy.Where_GetLastKnownLocationAsync_returns(null); //Act Sut.Connect(_requirements).Subscribe(next => { }, ex => { ExceptionTaskCompletionSource.SetResult(ex); }); //Assert MockAnalyticsService.VerifyTrace("Last known location is null"); }
public async Task IF_current_location_is_null_SHOULD_warn() { //Arrange MockProxy.Where_GetCurrentLocationAsync_returns(null); //Act Sut.Connect(_requirements).Subscribe(next => { }, ex => { ExceptionTaskCompletionSource.SetResult(ex); }); //Assert MockAnalyticsService.VerifyTrace("Current location is null", LogSeverity.Warning); }
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"); }
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"); }
public async Task IF_no_stored_handle_exists_SHOULD_return_empty_string_and_trace() { //Arrange MockSecureStorageService.Where_GetAsync_returns("PnsHandle", null); //Act var result = await Sut.GetPushNotificationServiceHandleAsync(); //Assert Assert.AreEqual(string.Empty, result); MockAnalyticsService.VerifyTrace("No PnsHandle found"); }
public async Task IF_location_returned_is_null_SHOULD_warn() { //Act var disposable = Sut.Connect(_requirements) .Subscribe(next => { }); //Assert MockProxy.Where_GetCurrentLocationAsync_returns(null); _testScheduler.AdvanceBy(1000); MockAnalyticsService.VerifyTrace("Updated location is null", LogSeverity.Warning); disposable.Dispose(); }