public void CanGetCarById() { CarsRepositoryMock repo = new CarsRepositoryMock(); Car car = repo.GetCarById(2); Assert.IsNotNull(car); Assert.AreEqual("2ABC2ABC2ABC2ABC2", car.VIN); Assert.AreEqual(2, car.CarId); Assert.AreEqual(new DateTime(2018, 1, 1), car.ModelYear); Assert.IsTrue(car.IsNew); Assert.IsFalse(car.IsSold); Assert.IsTrue(car.IsFeatured); Assert.AreEqual(5, car.UnitsInStock); Assert.AreEqual("200", car.Mileage); Assert.AreEqual(2, car.BodyColorId); Assert.AreEqual(2, car.BodyStyleId); Assert.AreEqual(2, car.TransmissionId); Assert.AreEqual(2, car.MakeId); Assert.AreEqual(3, car.ModelId); Assert.AreEqual(3, car.InteriorColorId); Assert.AreEqual(33000.00m, car.SalePrice); Assert.AreEqual(34150.00m, car.MSRP); Assert.AreEqual("/Images/2018AcuraTLX.png", car.IMGFilePath); Assert.AreEqual("A silver bullet of power and dependability.", car.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); }