public async void SingleApartmentIsNull_NotFoundResult() { // Arrange int apartmentId = 1; Mock <ApartmentRepository> mockApartmentRepository = new Mock <ApartmentRepository>(); mockApartmentRepository .Setup(ar => ar.GetAsync(It.IsAny <int>(), It.IsAny <string>())) .Returns(Task.FromResult(null as Apartment)); Mock <IUnitOfWork> mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork .Setup(u => u.GetRepository <Apartment, ApartmentRepository>()) .Returns(mockApartmentRepository.Object); ApartmentsController controller = new ApartmentsController(mockUnitOfWork.Object); // Act IActionResult result = await controller.Single(apartmentId); // Assert Assert.NotNull(result); Assert.IsType <NotFoundResult>(result); }
public async void SingleApartmentIdIsNull_NotFoundResult() { // Arrange Mock <IUnitOfWork> mockUnitOfWork = new Mock <IUnitOfWork>(); ApartmentsController controller = new ApartmentsController(mockUnitOfWork.Object); // Act IActionResult result = await controller.Single(null); // Assert Assert.NotNull(result); Assert.IsType <NotFoundResult>(result); }