public void TestLazyLoadProducts() { LazyLoader <ProductDomain, ProductDomain.Criteria> loader = new ProductLazyLoader(); IList <ProductDomain> list = new LazyLoadList <ProductDomain, ProductDomain.Criteria>(loader); IBaseMapper mapper = null; list.Add(new ProductDomain(mapper, ProductDomain.Criteria.SearchById(2))); list.Add(new ProductDomain(mapper, ProductDomain.Criteria.SearchById(4))); list.Add(new ProductDomain(mapper, ProductDomain.Criteria.SearchById(5))); ProductDomain product = list.FirstOrDefault(x => x.Id == 2); Assert.IsTrue(string.IsNullOrEmpty(product.Description)); //Description is not loaded Assert.AreEqual("Product two", list[0].Description); Assert.AreEqual("Product four", list[1].Description); Assert.AreEqual("Product five", list[2].Description); Assert.IsFalse(string.IsNullOrEmpty(product.Description)); //Description is now loaded }
public VerseListViewModel(DataSource source, DbList list) { if (list == null) throw new ArgumentNullException("list", "list cannot be null."); if (source == null) throw new ArgumentNullException("source", "source cannot be null."); var pageFactory = new VersePageFactory(source, list); var insertionStrategy = new VerseInsertionStrategy(source, list); _verseUpdateStrategy = new VerseUpdateStrategy(source, list); _verseList = new LazyLoadList<VerseViewModel>(pageFactory, insertionStrategy); Verses = _verseList; Title = list.Name; SelectedVerseIndex = -1; _dbList = list; ListId = _dbList.Id; }