public void CreditTypeRepository_Delete_Deletes() { // Arrange var repo = new CreditTypeRepository(); var existingItem = repo.Fetch(3).Single(); // Act existingItem.IsMarkedForDeletion = true; var deletedItem = repo.Persist(existingItem); // Assert for Delete Assert.IsNull(deletedItem); var emptyResult = repo.Fetch(3); Assert.IsFalse(emptyResult.Any()); }
public void CreditTypeRepository_FetchOne_ReturnsOne() { // Arrange var repo = new CreditTypeRepository(); var all = repo.Fetch(null).ToList(); var creditTypeId = all[0].Id; var name = all[0].Name; var item = repo.Fetch(creditTypeId).Single(); Assert.IsNotNull(item); Assert.IsTrue(item.Id == creditTypeId); Assert.IsTrue(item.Name == name); Assert.IsFalse(item.IsMarkedForDeletion); Assert.IsFalse(item.IsDirty); }
private Person CreateSamplePerson() { var newPerson = new Person { Salutation = "", FirstName = "Jane", MiddleName = "Anne", LastName = "TestLastName", Suffix = "", DateOfBirth = new DateTime(1943, 2, 5), HairColorId = 1, EyeColorId = 1 }; var creditTypeRepo = new CreditTypeRepository(); var creditTypes = creditTypeRepo.Fetch(null).ToList(); var showRepo = new ShowRepository(); var shows = showRepo.Fetch(null).ToList(); Credit crd1 = new Credit { ShowId = shows[0].Id, CreditTypeId = creditTypes[0].Id, Character = "Henry" }; newPerson.Credits.Add(crd1); return(newPerson); }
public void CreditTypeRepository_FetchNull_ReturnsAll() { // Arrange var repo = new CreditTypeRepository(); var list = repo.Fetch(); Assert.IsNotNull(list); Assert.IsTrue(list.Any()); }
public void CreditTypeRepository_InsertUpdateDelete() { // Arrange var repo = new CreditTypeRepository(); var newItem = new CreditType { Code = "TestCode", Name = "TestName", IsInactive = false, DisplayOrder = 99 }; var item = repo.Persist(newItem); var newId = item.Id; // Act for Update item.Name = "XYZ"; item.Code = "ABC"; item.IsInactive = true; item.DisplayOrder = 999; item.IsDirty = true; var updatedItem = repo.Persist(item); Assert.IsTrue(updatedItem.IsDirty == false); Assert.IsTrue(updatedItem.Name == "XYZ"); Assert.IsTrue(updatedItem.Code == "ABC"); Assert.IsTrue(updatedItem.IsInactive); Assert.IsTrue(updatedItem.DisplayOrder == 999); // Assert for Update var refetch = repo.Fetch(newId).First(); Assert.IsTrue(refetch.Name == "XYZ"); // Clean-up (Act for Delete) item.IsMarkedForDeletion = true; repo.Persist(item); // Assert for Delete var result = repo.Fetch(newId); Assert.IsFalse(result.Any()); }
public void Initialize() { _showRepo = new ShowRepository(); _ratingRepo = new MpaaRatingRepository(); _creditTypeRepo = new CreditTypeRepository(); _personRepo = new PersonRepository(); _ratings = _ratingRepo.Fetch().ToList(); _creditTypes = _creditTypeRepo.Fetch().ToList(); _shows = _showRepo.Fetch().ToList(); }
public void Initialize() { _showRepo = new ShowRepository(); _genreRepo = new GenreRepository(); _creditTypeRepo = new CreditTypeRepository(); _personRepo = new PersonRepository(); _genres = _genreRepo.Fetch().ToList(); _creditTypes = _creditTypeRepo.Fetch().ToList(); _people = _personRepo.Fetch().ToList(); }
public void CreditTypeRepository_InsertDelete() { // Arrange var repo = new CreditTypeRepository(); var newItem = new CreditType { Code = "TestCode", Name = "TestName", IsInactive = false, DisplayOrder = 99 }; // Act for Insert var item = repo.Persist(newItem); var newId = item.Id; // Assert for Insert - Make sure local object is updated Assert.IsTrue(item.Id > 0); Assert.IsFalse(item.IsMarkedForDeletion); Assert.IsFalse(item.IsDirty); // Assert for Insert - Make sure refetched object is correct var refetch = repo.Fetch(newId).First(); Assert.IsTrue(refetch.Id == newId); Assert.IsFalse(refetch.IsMarkedForDeletion); Assert.IsFalse(refetch.IsDirty); Assert.IsTrue(refetch.Code == "TestCode"); Assert.IsTrue(refetch.Name == "TestName"); Assert.IsTrue(refetch.IsInactive == false); Assert.IsTrue(refetch.DisplayOrder == 99); // Clean-up (Act for Delete) item.IsMarkedForDeletion = true; repo.Persist(item); // Assert for Delete var result = repo.Fetch(newId); Assert.IsFalse(result.Any()); }
public void CreditTypeRepository_FetchOne_ReturnsData() { // Arrange var repo = new CreditTypeRepository(); // Act var results = repo.Fetch(3); // Assert Assert.IsTrue(results != null); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Count() == 1); Assert.IsTrue(results.Single().CreditTypeId == 3); }
public void CreditTypeRepository_FetchAll_ReturnsData() { // Arrange var repo = new CreditTypeRepository(); // Act var results = repo.Fetch(); // Assert Assert.IsTrue(results != null); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Count() == 5); Assert.IsTrue(results.ToList()[4].Name == "Writer"); }
public void CreditTypeRepository_InsertUpdateDelete_Works() { // Arrange var repo = new CreditTypeRepository(); var testItem = new CreditType { Name = "TestItem", Code = "TestItemCode", IsInactive = true, DisplayOrder = 99 }; // Act - Insert var insertedItem = repo.Persist(testItem); var newId = insertedItem.CreditTypeId; // 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 PersonRepository_CreditDirty_SetsGraphDirty() { // Arrange var repo = new PersonRepository(); var all = repo.Fetch(null).ToList(); var personId = all[0].PersonId; var fullName = all[0].FullName; var item = repo.Fetch(personId).Single(); // Add one Credit to change a leaf // of the object graph var creditTypeRepository = new CreditTypeRepository(); var ct = creditTypeRepository.Fetch().First(); var showRepository = new ShowRepository(); var s = showRepository.Fetch().First(); var c = new Credit() { CreditTypeId = ct.CreditTypeId, ShowId = s.ShowId }; item.Credits.Add(c); Assert.IsNotNull(item); Assert.IsTrue(item.PersonId == personId); Assert.IsTrue(item.FullName == fullName); Assert.IsFalse(item.IsMarkedForDeletion); // The IsDirty flag should be false Assert.IsFalse(item.IsDirty); // The HasChanges property should // be true, indicating the change to ShowGenres Assert.IsTrue(item.IsGraphDirty); }
private Person CreateSamplePerson() { var newPerson = new Person { Salutation = "", FirstName = "Jane", MiddleName = "Anne", LastName = "TestLastName", Suffix = "", StageName = "", Weight = 120.5, DateOfBirth = new DateTime(1943, 2, 5), HairColorId = 1, EyeColorId = 1 }; var creditTypeRepo = new CreditTypeRepository(); var creditTypes = creditTypeRepo.Fetch(null).ToList(); var showRepo = new ShowRepository(); var shows = showRepo.Fetch(null).ToList(); Credit crd1 = new Credit { ShowId = shows[0].ShowId, CreditTypeId = creditTypes[0].CreditTypeId, Character = "Henry" }; newPerson.Credits.Add(crd1); return newPerson; }
public void CreditTypeRepository_Update_Updates() { // Arrange var repo = new CreditTypeRepository(); var existingItem = repo.Fetch(2).Single(); // Act - Update existingItem.Name = "TestItem1"; existingItem.Code = "TestItemCode1"; existingItem.IsInactive = false; existingItem.DisplayOrder = 10; repo.Persist(existingItem); // Assert for Update var updatedItem = repo.Fetch(2).Single(); Assert.IsTrue(updatedItem.Name == "TestItem1"); Assert.IsTrue(updatedItem.Code == "TestItemCode1"); Assert.IsTrue(updatedItem.IsInactive == false); Assert.IsTrue(updatedItem.DisplayOrder == 10); }
public void CreditTypeRepository_Insert_Insertss() { // Arrange var repo = new CreditTypeRepository(); var testItem = new CreditType { Name = "TestItem", Code = "TestItemCode", IsInactive = true, DisplayOrder = 99 }; // Act var insertedItem = repo.Persist(testItem); var newId = insertedItem.CreditTypeId; // 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); }