public void Update_Repo_OneRepoPlusReturned() { FakeGoodwillEntitesContext testContext = CreateContextWithTestData(); var repo = new FakeGenericRepository(testContext); //arrange var car = repo.GetByParam(x => x.CarModelID == 1); string fakeName = "Alfasud1"; //act car.Name = fakeName; repo.Update(car); testContext.SaveChanges(); var newCar = repo.GetByParam(x => x.CarModelID == 1); //asert Assert.AreEqual(fakeName, newCar.Name); }
/// <summary> /// Инициализация класса, имитирующего DbContext /// </summary> /// <returns></returns> private static FakeGoodwillEntitesContext CreateContextWithTestData() { var context = new FakeGoodwillEntitesContext { CarModels = { new CarModels { CarModelID = 1, ManufactorID = 1, Name = "One", IsShown = true }, new CarModels { CarModelID = 2, ManufactorID = 2, Name = "Two", IsShown = true }, new CarModels { CarModelID = 3, ManufactorID = 3, Name = "Three", IsShown = true } } }; return(context); }