public void EyeColorRepository_InsertUpdateDelete_Works() { // Arrange var repo = new EyeColorRepository(); var testItem = new EyeColor { Name = "TestItem", Code = "TestItemCode", IsInactive = true, DisplayOrder = 99 }; // Act - Insert var insertedItem = repo.Persist(testItem); var newId = insertedItem.EyeColorId; // Assert for Insert Assert.IsTrue(newId > 0); var existingItem = repo.Fetch(newId).Single(); Assert.IsTrue(existingItem.Name == "TestItem"); Assert.IsTrue(existingItem.Code == "TestItemCode"); Assert.IsTrue(existingItem.IsInactive == true); Assert.IsTrue(existingItem.DisplayOrder == 99); // Act - Update existingItem.Name = "TestItem1"; existingItem.Code = "TestItemCode1"; existingItem.IsInactive = false; existingItem.DisplayOrder = 10; repo.Persist(existingItem); // Assert for Update var updatedItem = repo.Fetch(newId).Single(); Assert.IsTrue(updatedItem.Name == "TestItem1"); Assert.IsTrue(updatedItem.Code == "TestItemCode1"); Assert.IsTrue(updatedItem.IsInactive == false); Assert.IsTrue(updatedItem.DisplayOrder == 10); // Act - Delete updatedItem.IsMarkedForDeletion = true; var deletedItem = repo.Persist(updatedItem); // Assert for Delete Assert.IsNull(deletedItem); var emptyResult = repo.Fetch(newId); Assert.IsFalse(emptyResult.Any()); }
public void EyeColorRepository_Insert_Insertss() { // Arrange var repo = new EyeColorRepository(); var testItem = new EyeColor { Name = "TestItem", Code = "TestItemCode", IsInactive = true, DisplayOrder = 99 }; // Act var insertedItem = repo.Persist(testItem); var newId = insertedItem.EyeColorId; // Assert Assert.IsTrue(newId > 0); var existingItem = repo.Fetch(newId).Single(); Assert.IsTrue(existingItem.Name == "TestItem"); Assert.IsTrue(existingItem.Code == "TestItemCode"); Assert.IsTrue(existingItem.IsInactive == true); Assert.IsTrue(existingItem.DisplayOrder == 99); }