public async void CreateModelIsNotValid_ViewResult()
        {
            // Arrange
            Apartment apartment = new Apartment {
                Id = 1
            };

            Mock <IUnitOfWork>   mockIUnitOfWork  = new Mock <IUnitOfWork>();
            Mock <IFileService>  mockIFileService = new Mock <IFileService>();
            ApartmentsController controller       = new ApartmentsController(mockIUnitOfWork.Object, mockIFileService.Object);

            controller.ModelState.AddModelError("RentEndDate", "Bad date!");

            // Act
            IActionResult result = await controller.Create(apartment, null);

            // Assert
            Assert.NotNull(result);
            ViewResult viewResult = Assert.IsType <ViewResult>(result);

            Assert.NotNull(viewResult.Model);
            Apartment apartmentModel = Assert.IsType <Apartment>(viewResult.Model);

            Assert.Same(apartment, apartmentModel);
            Assert.Null(viewResult.ViewName);
        }
        public async void Create_RedirectToAction()
        {
            // Arrange
            Apartment apartment = new Apartment {
                Id = 1
            };

            Mock <ApartmentRepository> mockApartamentRepository = new Mock <ApartmentRepository>();

            Mock <IUnitOfWork> mockIUnitOfWork = new Mock <IUnitOfWork>();

            mockIUnitOfWork
            .Setup(uw => uw.GetRepository <Apartment, ApartmentRepository>())
            .Returns(mockApartamentRepository.Object);

            Mock <IFileService> mockIFileService = new Mock <IFileService>();

            ApartmentsController controller = new ApartmentsController(mockIUnitOfWork.Object, mockIFileService.Object);

            // Act
            IActionResult result = await controller.Create(apartment, null);

            // Assert
            Assert.NotNull(result);
            RedirectToActionResult redirect = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal(nameof(ApartmentsController.Index), redirect.ActionName);
            Assert.Null(redirect.ControllerName);
        }
        public void Create_ViewResult()
        {
            // Arrange
            Mock <IUnitOfWork>   mockIUnitOfWork  = new Mock <IUnitOfWork>();
            Mock <IFileService>  mockIFileService = new Mock <IFileService>();
            ApartmentsController controller       = new ApartmentsController(mockIUnitOfWork.Object, mockIFileService.Object);

            // Act
            IActionResult result = controller.Create();

            // Assert
            Assert.NotNull(result);
            ViewResult viewResult = Assert.IsType <ViewResult>(result);

            Assert.Null(viewResult.ViewName);
        }