public void Insert_Repos_SomeReposCountReturned() { //arrange var testContext = CreateContextWithTestData(); var repo = new FakeGenericRepository(testContext); List <CarModels> list = new List <CarModels> { new CarModels { CarModelID = 4, ManufactorID = 5, Name = "Four" }, new CarModels { CarModelID = 5, ManufactorID = 6, Name = "Five" }, new CarModels { CarModelID = 6, ManufactorID = 7, Name = "Six" } }; var actualCount = repo.Get().Count(); //act repo.Insert(list); var expectedCount = repo.Get().Count(); var expected = repo.GetByParam(x => x.CarModelID == 6); //asert Assert.AreEqual(actualCount + 3, expectedCount); Assert.AreEqual(list[2].Name, expected.Name); }
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); }
public void GetByParam_Query_OneParametredQueryReturned() { //arrange var testContext = CreateContextWithTestData(); var repo = new FakeGenericRepository(testContext); int expectedId = 3; //act var actual = repo.GetByParam(x => x.CarModelID > 1 && x.Name == "Three"); //asert Assert.AreNotEqual(actual, null); Assert.AreEqual(actual.ManufactorID, expectedId); }
public void Insert_Repo_RepoPlusOneReturned() { //arrange var testContext = CreateContextWithTestData(); var repo = new FakeGenericRepository(testContext); var model = new CarModels { Name = "four", CarModelID = 4, ManufactorID = 5 }; var actualCount = repo.Get().Count(); //act repo.Insert(model); var expectedCount = repo.Get().Count(); var expectedRecord = repo.GetByParam(x => x.CarModelID == 4); //asert Assert.AreEqual(actualCount + 1, expectedCount); Assert.AreEqual(expectedRecord.Name, model.Name); }