public void DeleteItemCascadesDetails() { IRepository <ContentDetail> detailRepository = new NHRepository <ContentDetail>(sessionProvider); int itemID = 0; using (repository) { ContentItem item = CreateOneItem <Definitions.PersistableItem>(0, "item", null); item["TheString"] = "the string"; repository.Save(item); repository.Flush(); itemID = item.ID; } using (detailRepository) { Assert.AreEqual(1, detailRepository.Count()); } using (repository) { ContentItem item = repository.Get(itemID); repository.Delete(item); repository.Flush(); } using (detailRepository) { Assert.AreEqual(0, detailRepository.Count()); } }
public void CanDeleteDetail() { IRepository<ContentDetail> detailRepository = new NHRepository<ContentDetail>(sessionProvider); using (repository) { ContentItem item = CreateOneItem<Definitions.PersistableItem1>(0, "item", null); item["TheString"] = "the string"; repository.Save(item); repository.Flush(); Assert.AreEqual(1, detailRepository.Count()); item["TheString"] = null; repository.Save(item); repository.Flush(); Assert.AreEqual(0, detailRepository.Count()); } }
public void CanDeleteDetail() { IRepository <ContentDetail> detailRepository = new NHRepository <ContentDetail>(sessionProvider); using (repository) { ContentItem item = CreateOneItem <Definitions.PersistableItem>(0, "item", null); item["TheString"] = "the string"; repository.Save(item); repository.Flush(); Assert.AreEqual(1, detailRepository.Count()); item["TheString"] = null; repository.Save(item); repository.Flush(); Assert.AreEqual(0, detailRepository.Count()); } }
public void DeleteItemCascadesDetails() { IRepository<ContentDetail> detailRepository = new NHRepository<ContentDetail>(sessionProvider); int itemID = 0; using (repository) { ContentItem item = CreateOneItem<Definitions.PersistableItem1>(0, "item", null); item["TheString"] = "the string"; repository.Save(item); repository.Flush(); itemID = item.ID; } using(detailRepository) { Assert.AreEqual(1, detailRepository.Count()); } using(repository) { ContentItem item = repository.Get(itemID); repository.Delete(item); repository.Flush(); } using(detailRepository) { Assert.AreEqual(0, detailRepository.Count()); } }