Пример #1
0
        public void CanDeleteCar()
        {
            Car carToAdd = new Car();
            var repo     = new CarsRepositoryADO();

            carToAdd.MakeModelId     = 2;
            carToAdd.CarTypeId       = 2;
            carToAdd.BodyStyleId     = 2;
            carToAdd.TransmissionId  = 2;
            carToAdd.CarColorId      = 2;
            carToAdd.CarYear         = 1999;
            carToAdd.VIN             = 222;
            carToAdd.MSRP            = 17000M;
            carToAdd.SalePrice       = 16500M;
            carToAdd.CarDescription  = "Description2";
            carToAdd.Mileage         = 47000;
            carToAdd.InteriorColorId = 2;
            carToAdd.PicturePNG      = "Placeholder.png2";
            carToAdd.IsFeatured      = true;

            repo.Insert(carToAdd);

            var loaded = repo.GetById(2);

            Assert.IsNotNull(loaded);

            repo.Delete(2);
            loaded = repo.GetById(2);

            Assert.IsNull(loaded);
        }
Пример #2
0
        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!"
            };

            CarsRepositoryADO repo = new CarsRepositoryADO();

            repo.Insert(car);

            List <Car> cars = repo.GetAllCars().ToList();

            Assert.AreEqual(11, cars.Count);

            Assert.IsNotNull(cars[10].CarId);
            Assert.AreEqual("20000", cars[10].Mileage);
            Assert.AreEqual("5ABC5ABC5ABC5ABC5", cars[10].VIN);

            repo.Delete(10);

            List <Car> updatedCar = repo.GetAllCars().ToList();

            Car deletedCar = updatedCar.FirstOrDefault(c => c.CarId == 10);

            Assert.AreEqual(10, updatedCar.Count);

            Assert.IsNull(deletedCar);
        }