public void NPocoRepository_Update_Updates_Item_With_Correct_ID() { //Arrange var mockCache = new Mock <ICacheProvider>(); SetUpDatabase(TestConstants.NPOCO_RecordCount); var repository = new NPocoRepository <Dog>(_nPocoUnitOfWork, mockCache.Object); var dog = new Dog { ID = TestConstants.NPOCO_UpdateDogId, Age = TestConstants.NPOCO_UpdateDogAge, Name = TestConstants.NPOCO_UpdateDogName }; //Act repository.Update(dog); //Assert DataTable table = DataUtil.GetTable(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName); foreach (DataRow row in table.Rows) { if ((int)row["ID"] == TestConstants.NPOCO_UpdateDogId) { Assert.AreEqual(TestConstants.NPOCO_UpdateDogAge, row["Age"]); Assert.AreEqual(TestConstants.NPOCO_UpdateDogName, row["Name"]); } } }
public void NPocoRepository_Update_Updates_Item_In_DataBase() { //Arrange var mockCache = new Mock <ICacheProvider>(); SetUpDatabase(TestConstants.NPOCO_RecordCount); var repository = new NPocoRepository <Dog>(_nPocoUnitOfWork, mockCache.Object); var dog = new Dog { ID = TestConstants.NPOCO_UpdateDogId, Age = TestConstants.NPOCO_UpdateDogAge, Name = TestConstants.NPOCO_UpdateDogName }; //Act repository.Update(dog); //Assert int actualCount = DataUtil.GetRecordCount(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName); Assert.AreEqual(TestConstants.NPOCO_RecordCount, actualCount); }
public void NPocoRepository_Update_Updates_Item_With_Correct_ID() { //Arrange var mockCache = new Mock<ICacheProvider>(); SetUpDatabase(TestConstants.NPOCO_RecordCount); var repository = new NPocoRepository<Dog>(_nPocoUnitOfWork, mockCache.Object); var dog = new Dog { ID = TestConstants.NPOCO_UpdateDogId, Age = TestConstants.NPOCO_UpdateDogAge, Name = TestConstants.NPOCO_UpdateDogName }; //Act repository.Update(dog); //Assert DataTable table = DataUtil.GetTable(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName); foreach (DataRow row in table.Rows) { if ((int)row["ID"] == TestConstants.NPOCO_UpdateDogId) { Assert.AreEqual(TestConstants.NPOCO_UpdateDogAge, row["Age"]); Assert.AreEqual(TestConstants.NPOCO_UpdateDogName, row["Name"]); } } }
public void NPocoRepository_Update_Updates_Item_In_DataBase() { //Arrange var mockCache = new Mock<ICacheProvider>(); SetUpDatabase(TestConstants.NPOCO_RecordCount); var repository = new NPocoRepository<Dog>(_nPocoUnitOfWork, mockCache.Object); var dog = new Dog { ID = TestConstants.NPOCO_UpdateDogId, Age = TestConstants.NPOCO_UpdateDogAge, Name = TestConstants.NPOCO_UpdateDogName }; //Act repository.Update(dog); //Assert int actualCount = DataUtil.GetRecordCount(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName); Assert.AreEqual(TestConstants.NPOCO_RecordCount, actualCount); }