public void Delete() { // Arrange StatusController controller = new StatusController(); // Act controller.Delete(5); // Assert }
public async Task Delete_ReturnPartialViewAndStatusName_ByPassingBrandId() { // Arrange var brandId = 1; var status = GetListOfStatus().First(x => x.Id == brandId); mockStatusRepo.Setup(x => x.GetByIdAsync(It.IsAny <int?>())).ReturnsAsync(status); mockUOW.Setup(x => x.Repository <Status>()).Returns(mockStatusRepo.Object); var controller = new StatusController(mockUOW.Object); // Act var result = await controller.Delete(brandId); // Assert var viewResult = Assert.IsType <PartialViewResult>(result); var model = Assert.IsAssignableFrom <string>(viewResult.ViewData.Model); Assert.Equal(status.Name, model); }
public async Task DeletePost_RedirectAndDeleteStatus_ByPassingBrandId() { // Arrange var brandId = 1; var status = GetListOfStatus().First(x => x.Id == brandId); mockStatusRepo.Setup(x => x.GetByIdAsync(It.IsAny <int?>())).ReturnsAsync(status); mockStatusRepo.Setup(x => x.DeleteAsync(It.IsAny <Status>())).Returns(Task.FromResult(It.IsAny <int>())).Verifiable(); mockUOW.Setup(x => x.Repository <Status>()).Returns(mockStatusRepo.Object); var controller = new StatusController(mockUOW.Object); // Act var result = await controller.Delete(brandId, It.IsAny <IFormCollection>()); // Assert var redirectResult = Assert.IsType <RedirectToActionResult>(result); Assert.Null(redirectResult.ControllerName); Assert.Equal("Index", redirectResult.ActionName); mockStatusRepo.Verify(); }
public Status Delete(Status status) { return(statusController.Delete(status)); }