本文整理汇总了C#中BusinessObjectCollection.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# BusinessObjectCollection.Refresh方法的具体用法?C# BusinessObjectCollection.Refresh怎么用?C# BusinessObjectCollection.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusinessObjectCollection
的用法示例。
在下文中一共展示了BusinessObjectCollection.Refresh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: Test_RefreshAll_W_CreatedBO
public void Test_RefreshAll_W_CreatedBO()
{
//---------------Set up test pack-------------------
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.CreateBusinessObject();
RegisterForAddedAndRemovedEvents(cpCol);
//---------------Assert Precondition----------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
//---------------Execute Test ----------------------
cpCol.Refresh();
//---------------Test Result -----------------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
AssertAddedAndRemovedEventsNotFired();
}
示例3: Test_RefreshLoadedCollection_UsingNotLike
public void Test_RefreshLoadedCollection_UsingNotLike()
{
//---------------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();
var col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load("Surname not like %SSS%", "Surname");
//---------------Assert Precondition----------------
Assert.AreEqual(3, col.Count);
//---------------Execute Test ----------------------
CreateContactPersonInDB();
CreateContactPersonInDB();
ContactPersonTestBO cpNewLikeMatch = CreateContactPersonInDB_With_SSSSS_InSurname();
col.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(5, col.Count);
Assert.IsFalse(col.Contains(cpNewLikeMatch));
}
示例4: 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);
}
示例5: Test_AddedEvent_NotFiringWhenRefreshing
public void Test_AddedEvent_NotFiringWhenRefreshing()
{
//---------------Set up test pack-------------------
ContactPersonTestBO.LoadDefaultClassDef();
_addedEventFired = false;
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.LoadAll();
ContactPersonTestBO newCP = cpCol.CreateBusinessObject();
newCP.Surname = Guid.NewGuid().ToString();
newCP.Save();
cpCol.BusinessObjectAdded += delegate { _addedEventFired = true; };
//---------------Assert Preconditions --------------
Assert.IsFalse(_addedEventFired);
//---------------Execute Test ----------------------
cpCol.Refresh();
//---------------Test Result -----------------------
Assert.IsFalse(_addedEventFired);
}
示例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_Typed_NotEQ_CriteriaString_Null
public void Test_RefreshLoadedCollection_Typed_NotEQ_CriteriaString_Null()
{
//---------------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(now.AddHours(+1));
const string criteria = "DateOfBirth <> " + 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(cpEqual.DateOfBirth);
//---------------Assert Precondition ---------------
Assert.AreEqual(4, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.IsTrue(col.Contains(cpEqual));
//---------------Execute Test ----------------------
col.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(7, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.Contains(cp3, col);
Assert.Contains(cpNotEqual, col);
Assert.IsTrue(col.Contains(cpEqualNew));
Assert.IsTrue(col.Contains(cpEqual));
}
示例8: Test_MarkForDelete_Added_RefreshAll
public void Test_MarkForDelete_Added_RefreshAll()
{
//---------------Set up test pack-------------------
ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.Load(new Criteria("Surname", Criteria.ComparisonOp.Equals, TestUtil.GetRandomString()), "" );
cpCol.Add(myBO);
myBO.MarkForDelete();
_businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);
//---------------Assert Precondition----------------
BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
Assert.IsTrue(myBO.Status.IsDirty);
_businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
//---------------Execute Test ----------------------
cpCol.Refresh();
//---------------Test Result -----------------------
BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
Assert.IsTrue(myBO.Status.IsDirty);
_businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
}
示例9: Test_RefreshLoadedCollection_Typed_LTEQCriteriaString_IntegerProperty
public void Test_RefreshLoadedCollection_Typed_LTEQCriteriaString_IntegerProperty()
{
//---------------Set up test pack-------------------
LoadContactPersonClassDefWithIntProp();
DateTime now = DateTime.Now;
ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson(now);
cp1.SetPropertyValue("IntegerProperty", 0);
cp1.Save();
ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson(now);
cp2.SetPropertyValue("IntegerProperty", 1);
cp2.Save();
ContactPersonTestBO cpExcluded = ContactPersonTestBO.CreateSavedContactPerson(DateTime.Now.AddDays(+3));
cpExcluded.SetPropertyValue("IntegerProperty", 3);
cpExcluded.Save();
ContactPersonTestBO cpEqual = ContactPersonTestBO.CreateSavedContactPerson(now.AddHours(+1));
cpEqual.SetPropertyValue("IntegerProperty", 2);
cpEqual.Save();
string criteria = "IntegerProperty <= " + cpEqual.GetPropertyValue("IntegerProperty");
var col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "");
var cp3 = ContactPersonTestBO.CreateSavedContactPerson(now.AddDays(-1));
cp3.SetPropertyValue("IntegerProperty", 1);
cp3.Save();
var cpExcludeNew = ContactPersonTestBO.CreateSavedContactPerson(now.AddDays(+1));
cpExcludeNew.SetPropertyValue("IntegerProperty", 5);
cpExcludeNew.Save();
var cpEqualNew = ContactPersonTestBO.CreateSavedContactPerson(cpEqual.DateOfBirth);
cpEqualNew.SetPropertyValue("IntegerProperty", 2);
cpEqualNew.Save();
//---------------Assert Precondition ---------------
Assert.AreEqual(3, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.Contains(cpEqual, col);
Assert.IsFalse(col.Contains(cpExcluded));
//---------------Execute Test ----------------------
col.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(5, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.Contains(cp3, col);
Assert.Contains(cpEqual, col);
Assert.Contains(cpEqualNew, col);
Assert.IsFalse(col.Contains(cpExcludeNew));
Assert.IsFalse(col.Contains(cpExcluded));
}
示例10: Test_RefreshLoadedCollection_Typed_NotEQ_CriteriaString
public void Test_RefreshLoadedCollection_Typed_NotEQ_CriteriaString()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
LoadContactPersonClassDefWithIntProp();
ContactPersonTestBO cp1 = CreateSavedContactPerson(TestUtil.GetRandomString(), 2);
ContactPersonTestBO cp2 = CreateSavedContactPerson(TestUtil.GetRandomString(), 4);
CreateSavedContactPerson(TestUtil.GetRandomString(), 2);
ContactPersonTestBO cpEqual = CreateSavedContactPerson(TestUtil.GetRandomString(), 3);
string criteria = "IntegerProperty <> " + 3;
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "");
//---------------Assert Precondition ---------------
Assert.AreEqual(3, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
Assert.IsFalse(col.Contains(cpEqual));
//---------------Execute Test ----------------------
ContactPersonTestBO cp3 = CreateSavedContactPerson(TestUtil.GetRandomString(), 2);
ContactPersonTestBO cpNotEqual = CreateSavedContactPerson(TestUtil.GetRandomString(), 4);
ContactPersonTestBO cpEqualNew = CreateSavedContactPerson(TestUtil.GetRandomString(), 3);
col.Refresh();
//---------------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));
}
示例11: Test_Refresh_WithSavedBOAlreadyInCollection
public void Test_Refresh_WithSavedBOAlreadyInCollection()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
ContactPersonTestBO cp = ContactPersonTestBO.CreateUnsavedContactPerson();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.Add(cp);
cp.Save();
//---------------Assert preconditions---------------
Assert.AreEqual(1, cpCol.PersistedBusinessObjects.Count);
//---------------Execute Test ----------------------
cpCol.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(1, cpCol.PersistedBusinessObjects.Count);
}
示例12: Test_CollectionLoad_LoadWithLimit_FirstAtEnd_LimitBeyondEnd_RefreshWithAdditionalBO
public void Test_CollectionLoad_LoadWithLimit_FirstAtEnd_LimitBeyondEnd_RefreshWithAdditionalBO()
{
const int totalRecords = 5;
const int firstRecord = totalRecords - 1;
const int limit = 3;
SetupDefaultContactPersonBO();
var contactPersonTestBOs = CreateSavedContactPeople(totalRecords);
var contactPersonTestBOsPlusOne = new ContactPersonTestBO[totalRecords + 1];
contactPersonTestBOs.CopyTo(contactPersonTestBOsPlusOne, 0);
var col = new BusinessObjectCollection<ContactPersonTestBO>();
int totalNoOfRecords;
col.LoadWithLimit("", "Surname", firstRecord, limit, out totalNoOfRecords);
contactPersonTestBOsPlusOne[totalRecords] = ContactPersonTestBO.CreateSavedContactPerson
("ZZZZZZZZZZZZZZZZZ");
//---------------Assert Precondition----------------
Assert.AreEqual(1, col.Count);
Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
Assert.AreEqual(totalRecords + 1, contactPersonTestBOsPlusOne.Length);
//---------------Execute Test ----------------------
col.Refresh();
//---------------Test Result -----------------------
totalNoOfRecords++;
AssertLimitedResultsCorrect
(firstRecord, limit, totalRecords + 1, 2, contactPersonTestBOsPlusOne, col, totalNoOfRecords);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:25,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例13: Test_RefreshCollectionDoesNotRefreshDirtyOject
public void Test_RefreshCollectionDoesNotRefreshDirtyOject()
{
//---------------Set up test pack-------------------
BORegistry.DataAccessor = new DataAccessorDB();
ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
ContactPersonTestBO cp1 = CreateContactPersonTestBO();
col.Add(cp1);
string newSurname = Guid.NewGuid().ToString();
//--------------------Assert Preconditions----------
Assert.Contains(cp1 , col, "cp1 should be saved to the database");
//---------------Execute Test ----------------------
cp1.Surname = newSurname;
col.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(newSurname, cp1.Surname);
Assert.IsTrue(cp1.Status.IsDirty);
}
示例14: Test_RefreshCollectionRefreshesNonDirtyObjects
public void Test_RefreshCollectionRefreshesNonDirtyObjects()
{
//---------------Set up test pack-------------------
BORegistry.DataAccessor = new DataAccessorDB();
OrganisationTestBO.DeleteAllOrganisations();
ContactPersonTestBO.DeleteAllContactPeople();
SetupDefaultContactPersonBO();
var col = new BusinessObjectCollection<ContactPersonTestBO>();
var cp1 = CreateContactPersonTestBO();
FixtureEnvironment.ClearBusinessObjectManager();
CreateContactPersonTestBO();
CreateContactPersonTestBO();
col.LoadAll();
var newSurname = Guid.NewGuid().ToString();
cp1.Surname = newSurname;
cp1.Save();
var secondInstanceOfCP1 = col.Find(cp1.ContactPersonID);
//--------------------Assert Preconditions----------
AssertNotContains(cp1, col);
Assert.AreEqual(newSurname, cp1.Surname);
Assert.AreNotSame(secondInstanceOfCP1, cp1);
Assert.AreNotEqual(newSurname, secondInstanceOfCP1.Surname);
Assert.IsFalse(cp1.Status.IsDirty);
//---------------Execute Test ----------------------
col.Refresh();
//---------------Test Result -----------------------
Assert.AreNotSame(secondInstanceOfCP1, cp1);
Assert.AreEqual(newSurname, secondInstanceOfCP1.Surname);
}
示例15: Test_RefreshLoadedCollection_ISNull_CriteriaString
public void Test_RefreshLoadedCollection_ISNull_CriteriaString()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
DateTime now = DateTime.Now;
ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO.CreateSavedContactPerson(now);
ContactPersonTestBO.CreateSavedContactPerson(DateTime.Now.AddDays(+3));
ContactPersonTestBO cpEqual = ContactPersonTestBO.CreateSavedContactPerson(null, "sn", "fn");
const string criteria = "DateOfBirth IS NULL";
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
col.Load(criteria, "");
ContactPersonTestBO.CreateSavedContactPerson(now.AddDays(-1));
ContactPersonTestBO.CreateSavedContactPerson(now.AddDays(+1));
ContactPersonTestBO cpEqualNew = ContactPersonTestBO.CreateSavedContactPerson(null, "sn2", "fn2");
//---------------Assert Precondition ---------------
Assert.AreEqual(1, col.Count);
Assert.IsTrue(col.Contains(cpEqual));
//---------------Execute Test ----------------------
col.Refresh();
//---------------Test Result -----------------------
Assert.AreEqual(2, col.Count);
Assert.IsTrue(col.Contains(cpEqualNew));
Assert.IsTrue(col.Contains(cpEqual));
}