public async Task SHOULD_trace_success()
        {
            //Act
            await Sut.FromAddressAsync(_addressString);

            //Assert
            MockAnalyticsService.VerifyTrace("GPS cooridnates found from address");
            MockAnalyticsService.VerifyTraceProperty("Address", _addressString);
        }
Esempio n. 2
0
        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 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");
        }
Esempio n. 4
0
            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);
            }
Esempio n. 5
0
        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 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_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.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.SendNotificationToTargetAsync(_pushNotification, _target, MockNotificationHub.Object);

            //Assert
            MockAnalyticsService.VerifyTrace("Send push notification to device");
            MockAnalyticsService.VerifyTraceProperty(nameof(PushNotification), _pushNotification);
            MockAnalyticsService.VerifyTraceProperty(nameof(DeviceTarget), _target);
        }
Esempio n. 11
0
        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");
        }
Esempio n. 12
0
        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");
        }
Esempio n. 13
0
        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_extracted_notification()
        {
            //Arrange
            _target = DeviceTarget.iOS("pnsHandle");

            //Act
            await Sut.SendNotificationToTargetAsync(_pushNotification, _target, MockNotificationHub.Object);

            //Assert
            MockAnalyticsService.VerifyTrace("Native push notification extracted");
            MockAnalyticsService.VerifyTraceProperty(_iosNotification.GetType().Name, _iosNotification);
        }
        public async Task IF_no_locations_found_SHOULD_Error_and_trace()
        {
            //Arrange
            MockProxy.Where_GetLocationsFromAddressAsync_returns(new List <Location>());

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

            //Assert
            MockAnalyticsService.VerifyTrace("No GPS coordinates found for given address", LogSeverity.Warning);
            MockAnalyticsService.VerifyTraceProperty("Address", _addressString);
            Assert.That(result.IsError(GeolocationErrors.GpsCoordinatesNotFound));
        }
        public async Task IF_value_is_different_than_previous_one_SHOULD_log_analytics()
        {
            //Arrange
            MockSecureStorageService.Where_GetAsync_returns("new Handle");

            //Act
            await Sut.UpdatePushNotificationServiceHandleAsync("even newer Handle");

            //Assert
            MockAnalyticsService.VerifyTrace("PnsHandle updated", LogSeverity.Information);
            MockAnalyticsService.VerifyTraceProperty("OldPnsHandle", "new Handle");
            MockAnalyticsService.VerifyTraceProperty("NewPnsHandle", "even newer Handle");
        }
Esempio n. 17
0
        public async Task IF_no_placemarks_found_SHOULD_Error_and_trace()
        {
            //Arrange
            MockProxy.Where_GetPlacemarksFromLocationAsync_returns(new List <Placemark>());

            //Act
            var result = await Sut.ToAddressAsync(_gpsLocation);

            //Assert
            MockAnalyticsService.VerifyTrace("No address found for Gps coordinates", LogSeverity.Warning);
            MockAnalyticsService.VerifyTraceProperty(nameof(GpsLocation), _gpsLocation);
            Assert.That(result.IsError(GeolocationErrors.AddressNotFound));
        }
        public void SHOULD_trace_number_of_subscribers()
        {
            //Arrange
            Sut.ObserveForegroundNotifications().Subscribe();

            //Test
            Sut.HandleForegroundNotification(AndroidMessageProperties);

            //Assert
            MockAnalyticsService.VerifyStartTrace("Foreground Push Notification");
            MockAnalyticsService.VerifyTrace("Extracting push notification");
            MockAnalyticsService.VerifyTraceProperty("Raw Notification", AndroidMessageProperties);
            MockAnalyticsService.VerifyTrace("Notification processed");
            MockAnalyticsService.VerifyTrace("Foreground notification being published");
        }
Esempio n. 19
0
        public async Task IF_properties_does_not_include_Template_Name_SHOULD_ignore_but_log()
        {
            //Arrange
            var fakeNotification = new Dictionary <string, object>
            {
                { "profile", 0 }
            };

            //Act
            await Sut.HandleNotificationTappedAsync(fakeNotification);

            //Assert
            MockPushNotificationTapHandler.Mock.Verify(x => x.HandleTapAsync(It.IsAny <IPushNotification>()), Times.Never);
            MockAnalyticsService.VerifyTrace("Payload is not a notification: ignoring");
            MockAnalyticsService.VerifyTraceProperty("Raw Notification", fakeNotification);
        }