本文整理汇总了C#中BusinessObjectCollection.CancelEdits方法的典型用法代码示例。如果您正苦于以下问题:C# BusinessObjectCollection.CancelEdits方法的具体用法?C# BusinessObjectCollection.CancelEdits怎么用?C# BusinessObjectCollection.CancelEdits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusinessObjectCollection
的用法示例。
在下文中一共展示了BusinessObjectCollection.CancelEdits方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_MarkForDelete_Added_CancelEdits
public void Test_MarkForDelete_Added_CancelEdits()
{
//---------------Set up test pack-------------------
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
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 ----------------------
cpCol.CancelEdits();
//---------------Test Result -----------------------
BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol);
Assert.IsFalse(myBO.Status.IsDirty);
_businessObjectCollectionTestHelper.AssertAddedEventFired();
_businessObjectCollectionTestHelper.AssertRemovedEventFired();
}
示例2: Test_CreatedBusinessObject_CancelEdits
public void Test_CreatedBusinessObject_CancelEdits()
{
//---------------Set up test pack-------------------
//ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
ContactPersonTestBO newCP = cpCol.CreateBusinessObject();
newCP.Surname = TestUtil.GetRandomString();
RegisterForAddedAndRemovedEvents(cpCol);
//---------------Assert Precondition----------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
//---------------Execute Test ----------------------
cpCol.CancelEdits();
//---------------Test Result -----------------------
AssertAllCollectionsHaveNoItems(cpCol);
AssertRemovedEventFired();
}
示例3: Test_Add_PersistedBO_CancelEdits
public void Test_Add_PersistedBO_CancelEdits()
{
//---------------Set up test pack-------------------
//The persisted objects are added to the added cpCollection
// when restore is called the added objects should be removed from the cpCollection.
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
ContactPersonTestBO myBO2 = ContactPersonTestBO.CreateSavedContactPerson();
ContactPersonTestBO myBO3 = ContactPersonTestBO.CreateSavedContactPerson();
cpCol.Add(myBO, myBO2, myBO3);
_businessObjectCollectionTestHelper.RegisterForRemovedEvent(cpCol);
//-------Assert Preconditions
Assert.AreEqual(3, cpCol.Count, "Three objects should be in the copied cpCollection");
Assert.AreEqual(3, cpCol.AddedBusinessObjects.Count, "Three objects should be in the cpCollection");
_businessObjectCollectionTestHelper.AssertRemovedEventNotFired();
///---------------Execute Test ----------------------
cpCol.CancelEdits();
//---------------Test Result ----------------------- - Result
BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol);
_businessObjectCollectionTestHelper.AssertRemovedEventFired();
}
示例4: Test_RestoreAll
public void Test_RestoreAll()
{
ContactPersonTestBO.LoadDefaultClassDef();
ContactPersonTestBO contact1 = new ContactPersonTestBO {Surname = "Soap"};
ContactPersonTestBO contact2 = new ContactPersonTestBO {Surname = "Hope"};
BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO> {contact1, contact2};
col.SaveAll();
Assert.AreEqual("Soap", col[0].Surname);
Assert.AreEqual("Hope", col[1].Surname);
contact1.Surname = "Cope";
contact2.Surname = "Pope";
Assert.AreEqual("Cope", col[0].Surname);
Assert.AreEqual("Pope", col[1].Surname);
col.CancelEdits();
Assert.AreEqual("Soap", col[0].Surname);
Assert.AreEqual("Hope", col[1].Surname);
contact1.MarkForDelete();
contact2.MarkForDelete();
col.SaveAll();
Assert.AreEqual(0, col.Count);
}