public static BusinessObjectCollection GetHierarchicalData(int? parentId) { List<BusinessObject> result = GetData().FindAll(obj => obj.ParentID == parentId); BusinessObjectCollection ret = new BusinessObjectCollection(); ret.Clear(); ret.AddRange(result); return ret; }
public static BusinessObjectCollection GetData(int categoryId) { List<BusinessObject> result = GetData().FindAll(obj => obj.CategoryID == categoryId); BusinessObjectCollection ret = new BusinessObjectCollection(); ret.Clear(); ret.AddRange(result); return ret; }
public void Test_AddRange_ShouldFireEventsForEachItemAdded() { //---------------Set up test pack------------------- ContactPersonTestBO cp1; ContactPersonTestBO cp2; ContactPersonTestBO cp3; BusinessObjectCollection<ContactPersonTestBO> colOrig = CreateCollectionWithTestPack(out cp1, out cp2, out cp3); List<ContactPersonTestBO> list = new List<ContactPersonTestBO>(colOrig); BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>(); //---------------Assert Precondition---------------- Assert.AreNotEqual(0, list.Count); //---------------Execute Test ---------------------- int totalObjectAddedEventsFired = 0; col.BusinessObjectAdded += (sender, args) => totalObjectAddedEventsFired++; col.AddRange(list); //---------------Test Result ----------------------- Assert.AreEqual(list.Count, totalObjectAddedEventsFired); }
public void Test_AddRange_ShouldAddItemsToCol() { //---------------Set up test pack------------------- ContactPersonTestBO cp1; ContactPersonTestBO cp2; ContactPersonTestBO cp3; BusinessObjectCollection<ContactPersonTestBO> colOrig = CreateCollectionWithTestPack(out cp1, out cp2, out cp3); List<ContactPersonTestBO> list = new List<ContactPersonTestBO>(colOrig); BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>(); //---------------Assert Precondition---------------- Assert.AreEqual(3, colOrig.Count); Assert.AreEqual(3, list.Count); Assert.AreEqual(0, col.Count); //---------------Execute Test ---------------------- col.AddRange(list); //---------------Test Result ----------------------- Assert.AreEqual(3, colOrig.Count); Assert.AreEqual(3, list.Count); Assert.AreEqual(3, col.Count); }