本文整理汇总了C#中BusinessObjectCollection.Load方法的典型用法代码示例。如果您正苦于以下问题:C# BusinessObjectCollection.Load方法的具体用法?C# BusinessObjectCollection.Load怎么用?C# BusinessObjectCollection.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusinessObjectCollection
的用法示例。
在下文中一共展示了BusinessObjectCollection.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Find_ShouldReturnObject
public void Test_Find_ShouldReturnObject()
{
//---------------Set up test pack-------------------
ContactPersonTestBO.LoadDefaultClassDef();
// DateTime now = DateTime.Now;
const string firstName = "abab";
ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson("zzzz", firstName);
ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson("aaaa", firstName);
// Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now);
const string criteria = "FirstName = '" + firstName + "'";
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "Surname");
col.Sort("Surname", true, true);
//---------------Assert Precondition----------------
Assert.AreEqual(2, col.Count);
Assert.AreSame(cp2, col[0], "Collection should be in Surname Asc Order");
Assert.AreSame(cp1, col[1], "Collection should be in Surname Asc Order");
//---------------Execute Test ----------------------
ContactPersonTestBO foundCp = col.Find(bo => bo.Surname == "zzzz");
//---------------Test Result -----------------------
Assert.IsNotNull(foundCp);
Assert.AreSame(cp1, foundCp);
}
示例2: TestAddMethod_Refresh_LoadWithCriteria_BusinessObject
public void TestAddMethod_Refresh_LoadWithCriteria_BusinessObject()
{
//---------------Set up test pack-------------------
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.Load("Surname='bbb'", "");
ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("aaa");
cpCol.Add(myBO);
_businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);
//---------------Assert Precondition----------------
BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
Assert.IsFalse(myBO.Status.IsDirty);
_businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
//---------------Execute Test ----------------------
cpCol.Refresh();
//---------------Test Result -----------------------
BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
Assert.IsFalse(myBO.Status.IsDirty);
_businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
}
示例3: Test_MarkForDelete_Added_RestoreBO_LoadWCriteria
public void Test_MarkForDelete_Added_RestoreBO_LoadWCriteria()
{
//---------------Set up test pack-------------------
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.Load("Surname=cc", "");
ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB");
cpCol.Add(myBO);
myBO.MarkForDelete();
_businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);
//---------------Assert Precondition----------------
BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
Assert.IsTrue(myBO.Status.IsDirty);
//---------------Execute Test ----------------------
myBO.CancelEdits();
//---------------Test Result -----------------------
BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
Assert.IsFalse(myBO.Status.IsDirty);
_businessObjectCollectionTestHelper.AssertAddedEventFired();
_businessObjectCollectionTestHelper.AssertRemovedEventNotFired();
}
示例4: Test_Refresh_WithDuplicateObjectsInPersistedCollection_ShouldThrowHabaneroDeveloperException
public void Test_Refresh_WithDuplicateObjectsInPersistedCollection_ShouldThrowHabaneroDeveloperException()
{
//---------------Set up test pack-------------------
MyBO.LoadDefaultClassDef();
MyBO bo = new MyBO();
bo.Save();
BusinessObjectCollection<MyBO> collection = new BusinessObjectCollection<MyBO>();
collection.Load("MyBoID = '" + bo.MyBoID + "'", "");
collection.PersistedBusinessObjects.Add(bo);
//---------------Assert Precondition----------------
Assert.AreEqual(2, collection.PersistedBusinessObjects.Count);
Assert.AreSame(collection.PersistedBusinessObjects[0], collection.PersistedBusinessObjects[1]);
//---------------Execute Test ----------------------
try
{
collection.Refresh();
//---------------Test Result -----------------------
} catch (Exception ex)
{
Assert.IsInstanceOf<HabaneroDeveloperException>(ex, "Should have thrown a HabaneroDeveloperException because of the duplicate item in the PersistedBusinessObjects collection");
StringAssert.Contains("A duplicate Business Object was found in the persisted objects collection of the BusinessObjectCollection during a reload", ex.Message);
StringAssert.Contains("MyBO", ex.Message);
StringAssert.Contains(bo.MyBoID.Value.ToString("B").ToUpper(), ex.Message);
}
}
示例5: TestAcceptance_SearchGridSearchesTheGrid
public void TestAcceptance_SearchGridSearchesTheGrid()
{
//---------------Set up test pack-------------------
//Clear all contact people from the DB
BORegistry.DataAccessor = new DataAccessorInMemory();
IClassDef classDef = ContactPersonTestBO.LoadDefaultClassDefWithUIDef();
//Create data in the database with the 5 contact people two with Search in surname
CreateContactPersonInDB();
CreateContactPersonInDB();
CreateContactPersonInDB();
CreateContactPersonInDB_With_SSSSS_InSurname();
CreateContactPersonInDB_With_SSSSS_InSurname();
//Create grid setup for search
IReadOnlyGridControl readOnlyGridControl = CreateReadOnlyGridControl(true);
ITextBox txtbox = readOnlyGridControl.FilterControl.AddStringFilterTextBox("Surname", "Surname");
readOnlyGridControl.Initialise(classDef);
readOnlyGridControl.FilterMode = FilterModes.Search;
//--------------Assert PreConditions----------------
//No items in the grid
Assert.AreEqual(0, readOnlyGridControl.Grid.Rows.Count);
//---------------Execute Test ----------------------
//set data in grid to a value that should return 2 people
const string filterByValue = "SSSSS";
txtbox.Text = filterByValue;
//grid.filtercontrols.searchbutton.click
readOnlyGridControl.OrderBy = "Surname";
readOnlyGridControl.FilterControl.ApplyFilter();
//---------------Test Result -----------------------
StringAssert.Contains
(filterByValue, readOnlyGridControl.FilterControl.GetFilterClause().GetFilterClauseString());
//verify that there are 2 people in the grid.
Assert.AreEqual(2, readOnlyGridControl.Grid.Rows.Count);
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load("Surname like %" + filterByValue + "%", "Surname");
Assert.AreEqual(col.Count, readOnlyGridControl.Grid.Rows.Count);
int rowNum = 0;
foreach (ContactPersonTestBO person in col)
{
object rowID = readOnlyGridControl.Grid.Rows[rowNum++].Cells[_gridIdColumnName].Value;
Assert.AreEqual(person.ID.ToString(), rowID.ToString());
}
}
示例6: Test_RefreshLoadedCollection_Untyped_GTCriteriaObject_OrderClause_DoesNotLoadNewObject
Test_RefreshLoadedCollection_Untyped_GTCriteriaObject_OrderClause_DoesNotLoadNewObject()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
DateTime now = DateTime.Now;
ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson(now, "aaa");
ContactPersonTestBO cpLast = ContactPersonTestBO.CreateSavedContactPerson(now, "zzz");
ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson(now, "hhh");
ContactPersonTestBO.CreateSavedContactPerson(DateTime.Now.AddDays(-3));
Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.GreaterThan, now.AddHours(-1));
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "Surname");
ContactPersonTestBO cpnew = ContactPersonTestBO.CreateSavedContactPerson(now, "bbb");
//---------------Assert Precondition ---------------
Assert.AreEqual(3, col.Count);
//---------------Execute Test ----------------------
// BORegistry.DataAccessor.BusinessObjectLoader.Refresh(col);
col.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(4, col.Count);
Assert.AreSame(cp1, col[0]);
Assert.AreSame(cpnew, col[1]);
Assert.AreSame(cp2, col[2]);
Assert.AreSame(cpLast, col[3]);
}
示例7: Test_RefreshLoadedCollection_Untyped
public void Test_RefreshLoadedCollection_Untyped()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
DateTime now = DateTime.Now;
ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO.CreateSavedContactPerson(DateTime.Now.AddDays(-1));
Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now);
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "Surname");
ContactPersonTestBO cp3 = ContactPersonTestBO.CreateSavedContactPerson(now);
//---------------Assert Precondition ---------------
Assert.AreEqual(2, col.Count);
//---------------Execute Test ----------------------
// BORegistry.DataAccessor.BusinessObjectLoader.Refresh(col);
col.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(3, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.Contains(cp3, col);
}
示例8: Test_CollectionLoad_Load_GuidCriteria
public void Test_CollectionLoad_Load_GuidCriteria()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
DateTime now = DateTime.Now;
ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson();
//---------------Execute Test ----------------------
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load("ContactPersonID = '" + person.ContactPersonID + "'", "");
//---------------Test Result -----------------------
Assert.AreEqual(1, col.Count);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:16,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例9: Test_CollectionLoad_Load_CriteriaString_Untyped
public void Test_CollectionLoad_Load_CriteriaString_Untyped()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
// DateTime now = DateTime.Now;
const string firstName = "abab";
ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson("zzzz", firstName);
ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson("aaaa", firstName);
// Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now);
const string criteria = "FirstName = '" + firstName + "'";
//---------------Execute Test ----------------------
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "Surname");
//---------------Test Result -----------------------
Assert.AreEqual(2, col.Count);
col.Sort("Surname", true, true);
Assert.AreSame(cp2, col[0]);
Assert.AreSame(cp1, col[1]);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:21,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例10: Test_LoadUsingNotLike
public void Test_LoadUsingNotLike()
{
//---------------Set up test pack-------------------
ContactPerson.DeleteAllContactPeople();
SetupDefaultContactPersonBO();
//Create data in the database with the 5 contact people two with Search in surname
CreateContactPersonInDB();
CreateContactPersonInDB();
CreateContactPersonInDB();
CreateContactPersonInDB_With_SSSSS_InSurname();
CreateContactPersonInDB_With_SSSSS_InSurname();
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
//---------------Assert Precondition----------------
//---------------Execute Test ----------------------
col.Load("Surname Not like %SSS%", "Surname");
//---------------Test Result -----------------------
Assert.AreEqual(3, col.Count);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:20,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例11: Test_CollectionLoad_Load_NullCriteriaString
public void Test_CollectionLoad_Load_NullCriteriaString()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
DateTime now = DateTime.Now;
ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO.CreateSavedContactPerson();
//---------------Execute Test ----------------------
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load("", "Surname");
//---------------Test Result -----------------------
Assert.AreEqual(3, col.Count);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:16,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例12: Test_CollectionLoad_Load_CriteriaString
public void Test_CollectionLoad_Load_CriteriaString()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
// DateTime now = DateTime.Now;
const string surname = "abab";
ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson(surname);
ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson(surname);
ContactPersonTestBO.CreateSavedContactPerson();
// Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now);
const string criteria = "Surname = " + surname;
//---------------Execute Test ----------------------
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "Surname");
//---------------Test Result -----------------------
Assert.AreEqual(2, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:21,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例13: Test_CollectionLoad_Load_CriteriaString_ShouldSetUponLoadingCollection
public void Test_CollectionLoad_Load_CriteriaString_ShouldSetUponLoadingCollection()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
Criteria criteria = new Criteria("Surname", Criteria.ComparisonOp.Equals, "searchSurname");
const string stringCriteria = "Surname = searchSurname";
//---------------Execute Test ----------------------
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(stringCriteria, "Surname");
//---------------Test Result -----------------------
Assert.AreEqual(criteria, col.SelectQuery.Criteria);
Assert.AreEqual("ContactPersonTestBO.Surname ASC", col.SelectQuery.OrderCriteria.ToString());
Assert.AreEqual(-1, col.SelectQuery.Limit);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:16,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例14: CreateCollectionWithTestPack
private static BusinessObjectCollection<ContactPersonTestBO> CreateCollectionWithTestPack(string firstName, out ContactPersonTestBO cp1, out ContactPersonTestBO cp2, out ContactPersonTestBO cp3)
{
ContactPersonTestBO.LoadDefaultClassDef();
cp1 = ContactPersonTestBO.CreateSavedContactPerson("zzaaaa", firstName);
cp2 = ContactPersonTestBO.CreateSavedContactPerson("aaaa", firstName);
cp3 = ContactPersonTestBO.CreateSavedContactPerson("ZZZZZ", "FirstName");
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load("", "Surname");
col.Sort("Surname", true, true);
return col;
}
示例15: Test_RefreshLoadedCollection_IsNotNull_CriteriaString
public void Test_RefreshLoadedCollection_IsNotNull_CriteriaString()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
DateTime now = DateTime.Now;
ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO.CreateSavedContactPerson(DateTime.Now.AddDays(+3));
ContactPersonTestBO cpEqual = ContactPersonTestBO.CreateSavedContactPerson(null, "sn", "fn");
const string criteria = "DateOfBirth IS NOT NULL";
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "");
ContactPersonTestBO cp3 = ContactPersonTestBO.CreateSavedContactPerson(now.AddDays(-1));
ContactPersonTestBO cpNotEqual = ContactPersonTestBO.CreateSavedContactPerson(now.AddDays(+1));
ContactPersonTestBO cpEqualNew = ContactPersonTestBO.CreateSavedContactPerson(null, "sn2", "fn2");
//---------------Assert Precondition ---------------
Assert.AreEqual(3, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.IsFalse(col.Contains(cpEqual));
//---------------Execute Test ----------------------
//col.Refresh();
BORegistry.DataAccessor.BusinessObjectLoader.Refresh(col);
//---------------Test Result -----------------------
Assert.AreEqual(5, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.Contains(cp3, col);
Assert.Contains(cpNotEqual, col);
Assert.IsFalse(col.Contains(cpEqualNew));
Assert.IsFalse(col.Contains(cpEqual));
}