public async void Detail_ReturnNotFound(int?id) { // Arrange var mockRepo = new Mock <IAsyncRepository <Firm> >(); mockRepo.Setup(repo => repo.GetByIdAsync(id)).ReturnsAsync(GetFirms().Find(i => i.FirmId == id)); var controller = new FirmsController(mockRepo.Object); // Act var result = await controller.Details(id); // Assert Assert.IsType <NotFoundResult>(result); }
public async void Edit_GetCurrentItem(int?id) { // Arrange var mockRepo = new Mock <IAsyncRepository <Firm> >(); mockRepo.Setup(repo => repo.GetByIdAsync(id)).ReturnsAsync(GetFirms().Find(i => i.FirmId == id)); var controller = new FirmsController(mockRepo.Object); // Act var result = await controller.Edit(id); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <Firm>(viewResult.Model); Assert.Equal(id, model.FirmId); }