public void UpdateNotificationsReadStatusTests_InvalidApplicationName(string applicationName) { NotificationIdsContainer notificationIdsContainer = new NotificationIdsContainer { NotificationIds = new List <string> { "some Id" } }; var ex = Assert.ThrowsAsync <ArgumentException>(async() => await this.NotificationsControllerObject.UpdateNotificationsReadStatus(applicationName, notificationIdsContainer).ConfigureAwait(false)); Assert.IsTrue(ex.Message.StartsWith("Application name is mandatory", StringComparison.Ordinal)); }
public void UpdateNotificationsReadStatusTests_ValidInputs() { string notificationId = Guid.NewGuid().ToString(); NotificationIdsContainer notificationIdsContainer = new NotificationIdsContainer { NotificationIds = new List <string> { notificationId, } }; _ = this.NotificationsManagerMock.Setup(nm => nm.MarkNotificationsAsReadAsync(this.ApplicationName, notificationIdsContainer.NotificationIds)).Returns(Task.CompletedTask); var result = this.NotificationsControllerObject.UpdateNotificationsReadStatus(this.ApplicationName, notificationIdsContainer); Assert.IsTrue(result.Result.GetType().FullName.Equals(typeof(NoContentResult).FullName, StringComparison.Ordinal)); }
public async Task <IActionResult> UpdateNotificationsReadStatus(string applicationName, [FromBody] NotificationIdsContainer notificationIdsContainer) { IActionResult result = null; using (this.logger.BeginScope($"RootActivityId: {this.RootActivityId}")) { this.logger.LogInformation($"Started {nameof(this.UpdateNotificationsReadStatus)} method of {nameof(NotificationsController)}."); if (notificationIdsContainer is null) { throw new ArgumentNullException(nameof(notificationIdsContainer)); } if (string.IsNullOrWhiteSpace(applicationName)) { throw new ArgumentException("Application name is mandatory.", nameof(applicationName)); } await this.notificationsManager.MarkNotificationsAsReadAsync(applicationName, notificationIdsContainer.NotificationIds).ConfigureAwait(false); result = this.NoContent(); this.logger.LogInformation($"Finished {nameof(this.UpdateNotificationsReadStatus)} method of {nameof(NotificationsController)}."); } return(result); }