public void SetUp()
        {
            var context = new TestDbContext(_options);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
            _cars = Factory.TestCars();
            context.AddRange(_cars);
            context.SaveChanges();
            _context           = new TestDbContext(_options);
            _testCarRepository = new TestCarRepository(_context);
        }
示例#2
0
        public void should_Delete_Exisitng_By_Id()
        {
            var car = _cars.First();

            _testCarRepository.Delete(car.Id);

            _testCarRepository = new TestCarRepository(_context);

            var deletedCar = _testCarRepository.Find(car.Id);

            Assert.IsNull(deletedCar);
        }
        public void should_Delete_Exisitng()
        {
            var car = _cars.First();

            Assert.NotNull(car);
            _testCarRepository.Delete(car);
            _testCarRepository.SaveChanges();

            _testCarRepository = new TestCarRepository(_context);

            var deletedCar = _testCarRepository.Get(car.Id);

            Assert.IsNull(deletedCar);
        }
示例#4
0
        public void should_Update_Exisitng()
        {
            var car = _cars.First();

            car.Name = "GLE Benz";
            _testCarRepository.Update(car);

            _testCarRepository = new TestCarRepository(_context);

            var updatedCar = _testCarRepository.Find(car.Id);

            Assert.AreEqual("GLE Benz", updatedCar.Name);
            Console.WriteLine(updatedCar);
        }