public void CanAddCar() { Car car = new Car { ModelYear = new DateTime(2015, 1, 1), IsNew = false, IsFeatured = true, IsSold = false, UnitsInStock = 1, Mileage = "20000", VIN = "5ABC5ABC5ABC5ABC5", BodyColorId = 5, BodyStyleId = 3, TransmissionId = 2, MakeId = 3, ModelId = 2, InteriorColorId = 5, SalePrice = 19500m, MSRP = 21000m, IMGFilePath = "Images/placeholder.png", VehicleDetails = "2015 Ford Escape. Fully Loaded!" }; CarsRepositoryMock repo = new CarsRepositoryMock(); repo.Insert(car); List <Car> cars = repo.GetAllCars().ToList(); Assert.AreEqual(11, cars.Count); Assert.AreEqual(5, cars[4].CarId); Assert.AreEqual(car.ModelYear, cars[10].ModelYear); Assert.AreEqual(car.IsNew, cars[10].IsNew); Assert.AreEqual(car.IsFeatured, cars[10].IsFeatured); Assert.AreEqual(car.IsSold, cars[10].IsSold); Assert.AreEqual(car.UnitsInStock, cars[10].UnitsInStock); Assert.AreEqual(car.Mileage, cars[10].Mileage); Assert.AreEqual(car.VIN, cars[10].VIN); Assert.AreEqual(car.BodyColorId, cars[10].BodyColorId); Assert.AreEqual(car.BodyStyleId, cars[10].BodyStyleId); Assert.AreEqual(car.TransmissionId, cars[10].TransmissionId); Assert.AreEqual(car.MakeId, cars[10].MakeId); Assert.AreEqual(car.ModelId, cars[10].ModelId); Assert.AreEqual(car.InteriorColorId, cars[10].InteriorColorId); Assert.AreEqual(car.SalePrice, cars[10].SalePrice); Assert.AreEqual(car.MSRP, cars[10].MSRP); Assert.AreEqual(car.IMGFilePath, cars[10].IMGFilePath); Assert.AreEqual(car.VehicleDetails, cars[10].VehicleDetails); }
public void CanDeleteCar() { Car car = new Car { ModelYear = new DateTime(2015, 1, 1), IsNew = false, IsFeatured = true, IsSold = false, UnitsInStock = 1, Mileage = "20000", VIN = "5ABC5ABC5ABC5ABC5", BodyColorId = 5, BodyStyleId = 3, TransmissionId = 2, MakeId = 3, ModelId = 2, InteriorColorId = 5, SalePrice = 19500m, MSRP = 21000m, IMGFilePath = "Images/placeholder.png", VehicleDetails = "2015 Ford Escape. Fully Loaded!" }; CarsRepositoryMock repo = new CarsRepositoryMock(); repo.Insert(car); var newCar = repo.GetCarById(5); Assert.IsNotNull(newCar); repo.Delete(5); newCar = repo.GetCarById(5); Assert.IsNull(newCar); }
public void CanUpdateCar() { Car car = new Car { ModelYear = new DateTime(2015, 1, 1), IsNew = false, IsFeatured = true, IsSold = false, UnitsInStock = 1, Mileage = "20000", VIN = "5ABC5ABC5ABC5ABC5", BodyColorId = 5, BodyStyleId = 3, TransmissionId = 2, MakeId = 3, ModelId = 2, InteriorColorId = 5, SalePrice = 19500m, MSRP = 21000m, IMGFilePath = "Images/placeholder.png", VehicleDetails = "2015 Ford Escape. Fully Loaded!" }; CarsRepositoryMock repo = new CarsRepositoryMock(); repo.Insert(car); car.BodyColorId = 2; car.InteriorColorId = 5; car.SalePrice = 17500m; car.MSRP = 19200m; car.IMGFilePath = "Images/updatedImage.png"; car.IsSold = true; car.IsNew = true; car.IsFeatured = true; car.VIN = "6ABC6ABC6ABC6ABC6"; car.VehicleDetails = "Updated"; car.Mileage = "3"; car.ModelYear = new DateTime(2018, 1, 1); car.MakeId = 2; car.ModelId = 3; car.TransmissionId = 1; car.UnitsInStock = 9; car.BodyStyleId = 2; repo.Update(car); var updatedCar = repo.GetCarById(11); Assert.AreEqual(updatedCar.BodyStyleId, 2); Assert.AreEqual(updatedCar.BodyColorId, 2); Assert.AreEqual(updatedCar.InteriorColorId, 5); Assert.AreEqual(updatedCar.IMGFilePath, "Images/updatedImage.png"); Assert.AreEqual(updatedCar.SalePrice, 17500m); Assert.AreEqual(updatedCar.MSRP, 19200m); Assert.AreEqual(updatedCar.IsNew, true); Assert.AreEqual(updatedCar.IsFeatured, true); Assert.AreEqual(updatedCar.IsSold, true); Assert.AreEqual(updatedCar.VIN, "6ABC6ABC6ABC6ABC6"); Assert.AreEqual(updatedCar.VehicleDetails, "Updated"); Assert.AreEqual(updatedCar.Mileage, "3"); Assert.AreEqual(updatedCar.ModelYear, new DateTime(2018, 1, 1)); Assert.AreEqual(updatedCar.MakeId, 2); Assert.AreEqual(updatedCar.ModelId, 3); Assert.AreEqual(updatedCar.TransmissionId, 1); Assert.AreEqual(updatedCar.UnitsInStock, 8); }