public void Get_ViewResult_Create_Test() { SubscribersController controller = new SubscribersController(); var result = controller.Create(); Assert.IsType <ViewResult>(result); }
public void Create_ReturnsViewResultWithoutModel() { // Arrange var mockRepo = new Mock <IInvoicesRepository>(); var controller = new SubscribersController(mockRepo.Object); // Act var result = controller.Create(); // Assert var viewResult = Assert.IsType <ViewResult>(result); Assert.Null(viewResult.ViewData.Model); }
public async Task Create_RedirectsToIndex() { var Subscriber = new Subscriber() { Id = 1 }; // Arrange var mockRepo = new Mock <IInvoicesRepository>(); mockRepo.Setup(repo => repo.AddSubscriberAsync(Subscriber)) .ReturnsAsync(Subscriber); var controller = new SubscribersController(mockRepo.Object); // Act var result = await controller.Create(Subscriber); // Assert var redirect = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Index", redirect.ActionName); }