Beispiel #1
0
        public void Delete_given_carid_deletes_car()
        {
            var cc = new CarCRUD(context);

            var car = new Car {
                Name = "Car Four", DriverName = "Driver Four"
            };

            cc.Create(car);

            var carToDelete = new Car {
                Name = "Car Four", DriverName = "Driver Four"
            };

            cc.Delete(carToDelete.CarId);
            bool notDeleted = context.Car.Any(c => c.CarId == carToDelete.CarId);

            Assert.False(notDeleted);
        }
Beispiel #2
0
        public void TestDelete()
        {
            Cars car = new Cars {
                Name = "hej", DriverName = "hehe"
            };

            using (RaceContext context = new RaceContext())
            {
                context.Cars.Add(car);
                context.SaveChanges();
            }
            using (CarCRUD CarCRUD = new CarCRUD(new RaceContext()))
            {
                CarCRUD.Delete(car.Id);
            }
            using (RaceContext context = new RaceContext())
            {
                Assert.Null(context.Cars.Find(car.Id));
            }
        }