public async Task AddNotificationList_InValid_ThrowException() { //Arrange _notificationService.Setup(cs => cs.AddListUserNotificationAsync(It.IsAny <IEnumerable <UserNotificationDTO> >())).ThrowsAsync(new InvalidOperationException()); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.AddNotificationList(new List <UserNotificationDTO>()); //Assert Assert.IsInstanceOf <BadRequestResult>(result); }
public async Task GetAllUserNotification_Valid_Test(string id) { //Arrange _notificationService.Setup(cs => cs.GetAllUserNotificationsAsync(It.IsAny <string>())).ReturnsAsync(new List <UserNotificationDTO>()); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.GetAllUserNotification(id); //Assert Assert.IsInstanceOf <OkObjectResult>(result); Assert.NotNull(result); }
public async Task GetAllTypes_Valid_Test() { //Arrange _notificationService.Setup(cs => cs.GetAllNotificationTypesAsync()).ReturnsAsync(new List <NotificationTypeDTO>()); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.GetAllTypes(); //Assert Assert.IsInstanceOf <OkObjectResult>(result); Assert.NotNull(result); }
public async Task AddNotificationList_Valid_ReturnsNoContent() { //Arrange _notificationService.Setup(cs => cs.AddListUserNotificationAsync(It.IsAny <IEnumerable <UserNotificationDTO> >())).ReturnsAsync(new List <UserNotificationDTO>()); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.AddNotificationList(new List <UserNotificationDTO>()); //Assert Assert.IsInstanceOf <NoContentResult>(result); }
public async Task RemoveAllUserNotifications_Valid_Test(string id) { //Arrange bool successRemoved = true; _notificationService.Setup(cs => cs.RemoveAllUserNotificationAsync(It.IsAny <string>())).ReturnsAsync(successRemoved); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.RemoveAllUserNotifications(id); //Assert Assert.IsInstanceOf <NoContentResult>(result); }
public async Task RemoveUserNotification_InValid_Test(int id) { //Arrange bool successRemoved = false; _notificationService.Setup(cs => cs.RemoveUserNotificationAsync(It.IsAny <int>())).ReturnsAsync(successRemoved); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.RemoveUserNotification(id); //Assert Assert.IsInstanceOf <BadRequestResult>(result); }
public async Task SetCheckForListNotification_InValid_Test() { //Arrange bool successSetCheck = false; _notificationService.Setup(cs => cs.SetCheckForListNotificationAsync(It.IsAny <string>())).ReturnsAsync(successSetCheck); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.SetCheckForListNotification("2"); //Assert Assert.IsInstanceOf <BadRequestResult>(result); }
public async Task SetCheckForListNotification_Valid_Test() { //Arrange bool successSetCheck = true; _notificationService.Setup(cs => cs.SetCheckForListNotificationAsync(It.IsAny <IEnumerable <int> >())).ReturnsAsync(successSetCheck); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.SetCheckForListNotification(new List <int>()); //Assert Assert.IsInstanceOf <NoContentResult>(result); }
public async Task GetAllTypes_Valid_Test() { //Arrange var list = new List <NotificationTypeDTO>() { new NotificationTypeDTO() }; _notificationService.Setup(cs => cs.GetAllNotificationTypesAsync()).ReturnsAsync(list); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.GetAllTypes(); //Assert Assert.AreEqual(((result as ObjectResult).Value as IEnumerable <NotificationTypeDTO>).Count(), list.Count); Assert.IsInstanceOf <OkObjectResult>(result); Assert.NotNull(result); }
public async Task GetAllUserNotification_Valid_Test(string id) { //Arrange var list = new List <UserNotificationDTO>() { new UserNotificationDTO() }; _notificationService.Setup(cs => cs.GetAllUserNotificationsAsync(It.IsAny <string>())).ReturnsAsync(list); NotificationBoxController notificationBoxController = _notificationBoxController; //Act var result = await notificationBoxController.GetAllUserNotification(id); var resultCount = ((IEnumerable <UserNotificationDTO>)(result as ObjectResult).Value).Count(); //Assert Assert.IsInstanceOf <OkObjectResult>(result); Assert.AreEqual(resultCount, list.Count); Assert.NotNull(result); }