public void CreateAndEditReturnTheirViewsOnValidationException()
        {
            // Arrange
            var mockRentService = new Mock <IRentService>();

            mockRentService.Setup(a => a.GetCar(0)).Throws(new ValidationException("test", "test"));
            mockRentService.Setup(a => a.UpdateCar(It.IsAny <CarDTO>())).Throws(new ValidationException("test", "test"));
            mockRentService.Setup(a => a.CreateCar(It.IsAny <CarDTO>())).Throws(new ValidationException("test", "test"));

            var controller = new CarAdminController(mockRentService.Object);

            controller.ControllerContext = new FakeControllerContext(controller, new FormCollection());

            // Act
            var resultCreate = controller.Create(new CarViewModel(), null) as ViewResult;
            var resultEdit   = controller.Edit(new CarViewModel(), null) as ViewResult;

            // Assert
            Assert.That(resultCreate, Is.Not.Null);
            // ReSharper disable once PossibleNullReferenceException
            Assert.That(resultCreate.Model, Is.TypeOf(typeof(CarViewModel)));

            Assert.That(resultEdit, Is.Not.Null);
            // ReSharper disable once PossibleNullReferenceException
            Assert.That(resultEdit.Model, Is.TypeOf(typeof(CarViewModel)));
        }
        public void CreateAndEditRedirectToIndexOnSuccess()
        {
            // Arrange
            var mockRentService = new Mock <IRentService>();

            mockRentService.Setup(a => a.GetCar(It.IsAny <int>())).Returns(new CarDTO());

            var controller = new CarAdminController(mockRentService.Object);

            controller.ControllerContext = new FakeControllerContext(controller, new FormCollection());

            // Act
            var resultCreate = controller.Create(new CarViewModel(), null);
            var resultEdit   = controller.Edit(new CarViewModel(), null);

            // Assert
            // ReSharper disable once PossibleNullReferenceException
            Assert.That(resultCreate, Is.TypeOf(typeof(RedirectToRouteResult)));
            // ReSharper disable once PossibleNullReferenceException
            Assert.That(resultEdit, Is.TypeOf(typeof(RedirectToRouteResult)));
        }