public void ReadNotificationsStatusAsync_InvalidApplicationName(string applicationName) { NotificationTrackingIdsContainer notificationTrackingIdsContainer = new NotificationTrackingIdsContainer(); notificationTrackingIdsContainer.TrackingIds = new List <string> { Guid.NewGuid().ToString() }; var ex = Assert.ThrowsAsync <ArgumentException>(async() => await this.NotificationsControllerObject.ReadNotificationsStatusAsync(applicationName, notificationTrackingIdsContainer).ConfigureAwait(false)); Assert.IsTrue(ex.Message.StartsWith("Application name is mandatory.", StringComparison.Ordinal)); }
public async Task ReadNotificationsStatusAsync_ValidInputs() { NotificationTrackingIdsContainer notificationTrackingIdsContainer = new NotificationTrackingIdsContainer(); string trackingId = Guid.NewGuid().ToString(); WebNotificationStatusResponse response = new WebNotificationStatusResponse(); WebNotificationStatus notificationStatus = new WebNotificationStatus { NotificationId = Guid.NewGuid().ToString(), TrackingId = trackingId, ReadStatus = NotificationReadStatus.New, IsValidTrackingId = true, }; notificationStatus.DeliveryStatus.Add("Web", true); response.NotificationStatus.Add(notificationStatus); _ = this.NotificationsManagerMock.Setup(nm => nm.LoadNotificationStatusAsync(It.IsAny <string>(), It.IsAny <IEnumerable <string> >())).Returns(Task.FromResult(response)); var statusResponse = await this.NotificationsControllerObject.ReadNotificationsStatusAsync(this.ApplicationName, notificationTrackingIdsContainer).ConfigureAwait(false); Assert.IsTrue(statusResponse.GetType().FullName.Equals(typeof(OkObjectResult).FullName, StringComparison.Ordinal)); this.NotificationsManagerMock.Verify(nm => nm.LoadNotificationStatusAsync(It.IsAny <string>(), It.IsAny <IEnumerable <string> >()), Times.Once); }
public async Task <IActionResult> ReadNotificationsStatusAsync(string applicationName, [FromBody] NotificationTrackingIdsContainer notificationTrackingIdsContainer) { IActionResult result = null; using (this.logger.BeginScope($"RootActivityId: {this.RootActivityId}")) { this.logger.LogInformation($"Started {nameof(this.ReadNotificationsStatusAsync)} method of {nameof(NotificationsController)}."); if (string.IsNullOrWhiteSpace(applicationName)) { throw new ArgumentException("Application name is mandatory.", nameof(applicationName)); } if (notificationTrackingIdsContainer == null) { throw new ArgumentNullException(nameof(notificationTrackingIdsContainer)); } WebNotificationStatusResponse statusResponse = await this.notificationsManager.LoadNotificationStatusAsync(applicationName, notificationTrackingIdsContainer.TrackingIds).ConfigureAwait(false); result = this.Ok(statusResponse); this.logger.LogInformation($"Finished {nameof(this.ReadNotificationsStatusAsync)} method of {nameof(NotificationsController)}."); } return(result); }