public IActionResult UpdateCar(CarViewModel updateCarViewModel) { Car car = carManager.GetCar(updateCarViewModel.StateNumber); car.Color = updateCarViewModel.Color; car.Manufacturer = updateCarViewModel.Make; car.Model = updateCarViewModel.Model; car.Year = updateCarViewModel.Year.Value; carManager.CarUpdate(car); return(RedirectToAction("CarSettings")); }
public void CarUpdateExceptionTest() { Car car = null; try { CarManager carManager = new CarManager(contextFactory); Car changedCar = carManager.CarUpdate(car); Assert.NotNull(changedCar); } catch (ArgumentNullException ex) { Assert.True(ex is ArgumentNullException); } }
public void CarUpdateTest() { Car car = new Car(); using (ParkingDBContext context = contextFactory.CreateDbContext()) { CarEntity carEntity = new CarEntity(); carEntity.StateNumber = "1234-AA7"; context.Cars.Add(carEntity); car.Id = carEntity.IdCar; context.SaveChanges(); } car.StateNumber = "1478 -AA7"; CarManager carManager = new CarManager(contextFactory); Car changedCar = carManager.CarUpdate(car); Assert.NotNull(changedCar); Assert.Equal(changedCar.StateNumber, car.StateNumber); }