public async Task Update_ReturnsUpdatedNotification() { string userNotificationsJson = File.ReadAllText(TestConfiguration.MockDataFolderPath + @"UserNotifications.json"); var notification = JsonConvert.DeserializeObject <List <UserNotification> >(userNotificationsJson).First(u => u.User.Id == TESTING_USER_ID); const string newTitle = "Test title"; const string newContent = "Test content"; var userNotification = new UserNotification { Id = notification.Id, Title = newTitle, Content = newContent, IsRead = true }; UserNotificationRepository.Setup(u => u.GetByKey(userNotification.Id)).Returns(notification); UserNotificationRepository.Setup(n => n.Update(notification)).ReturnsAsync(notification); var resultUserNotification = await UserNotificationService.Update(userNotification); Assert.NotNull(resultUserNotification); Assert.Equal(newTitle, resultUserNotification.Title); Assert.Equal(newContent, resultUserNotification.Content); Assert.Equal(notification.CreatedDate, resultUserNotification.CreatedDate); Assert.True(resultUserNotification.IsRead); }
public IActionResult Update(Guid id, [FromBody] UserNotificationInfo item) { if (ModelState.IsValid) { _userNotificationService.Update(id, item); return(Ok(item)); } return(BadRequest(ModelState)); }