本文整理汇总了C#中BusinessObjectCollection.CreateBusinessObject方法的典型用法代码示例。如果您正苦于以下问题:C# BusinessObjectCollection.CreateBusinessObject方法的具体用法?C# BusinessObjectCollection.CreateBusinessObject怎么用?C# BusinessObjectCollection.CreateBusinessObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusinessObjectCollection
的用法示例。
在下文中一共展示了BusinessObjectCollection.CreateBusinessObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_BindBusinessObjectCollection_ToListBox_ShouldAddToControlList
public void Test_BindBusinessObjectCollection_ToListBox_ShouldAddToControlList()
{
//---------------Set up test pack-------------------
var lstBox = new ListBox();
var selectorBinder = new HabaneroSelectorControlBinder<FakeBo, ListBox>(lstBox);
var businessObjectCollection = new BusinessObjectCollection<FakeBo>();
businessObjectCollection.CreateBusinessObject();
//---------------Assert Precondition----------------
Assert.AreEqual(0, lstBox.Items.Count);
//---------------Execute Test ----------------------
selectorBinder.SetBusinessObjectCollection(businessObjectCollection);
//---------------Test Result -----------------------
Assert.AreEqual(1, lstBox.Items.Count, "The business object collection's items should be in list");
}
示例2: Test_CreateBusObject
public void Test_CreateBusObject()
{
//---------------Set up test pack-------------------
//ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.LoadAll();
RegisterForAddedEvent(cpCol);
//---------------Assert Precondition----------------
Assert.AreEqual(0, cpCol.Count);
Assert.IsFalse(_addedEventFired);
Assert.AreEqual(0, cpCol.PersistedBusinessObjects.Count);
//---------------Execute Test ----------------------
ContactPersonTestBO newCP = cpCol.CreateBusinessObject();
//---------------Test Result -----------------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
Assert.Contains(newCP, cpCol.CreatedBusinessObjects);
Assert.Contains(newCP, cpCol);
Assert.IsFalse(cpCol.PersistedBusinessObjects.Contains(newCP));
Assert.IsTrue(_addedEventFired);
}
示例3: GetBusinessObjectCollectionWith3Items
private static BusinessObjectCollection<FakeBo> GetBusinessObjectCollectionWith3Items()
{
var businessObjectCollection = new BusinessObjectCollection<FakeBo>();
businessObjectCollection.CreateBusinessObject();
businessObjectCollection.CreateBusinessObject();
businessObjectCollection.CreateBusinessObject();
return businessObjectCollection;
}
示例4: Test_CreatedBusinessObject_SaveBO
public void Test_CreatedBusinessObject_SaveBO()
{
//Saving a created business object should remove the business
// object from the created col. it should still exist in
// the main collection and should be added to the persisted collection
//---------------Set up test pack-------------------
//ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
cpCol.LoadAll();
ContactPersonTestBO newCP = cpCol.CreateBusinessObject();
newCP.Surname = TestUtil.GetRandomString();
RegisterForAddedEvent(cpCol);
//---------------Assert Preconditions --------------
Assert.IsFalse(_addedEventFired);
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
//---------------Execute Test ----------------------
newCP.Save();
//---------------Test Result -----------------------
Assert.IsFalse(_addedEventFired);
Assert.Contains(newCP, cpCol);
AssertOneObjectInCurrentAndPersistedCollection(cpCol);
}
示例5: 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();
}
示例6: Test_CreatedBusinessObject_Add
public void Test_CreatedBusinessObject_Add()
{
//---------------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.Add(newCP);
//---------------Test Result -----------------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
AssertAddedAndRemovedEventsNotFired();
}
示例7: Test_CreatedBusinessObject_Refresh
public void Test_CreatedBusinessObject_Refresh()
{
//---------------Set up test pack-------------------
//ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
ContactPersonTestBO newCP = cpCol.CreateBusinessObject();
newCP.Surname = TestUtil.GetRandomString();
//---------------Assert Precondition----------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
//---------------Execute Test ----------------------
BORegistry.DataAccessor.BusinessObjectLoader.Refresh(newCP);
//---------------Test Result -----------------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
}
示例8: Test_ClearClearsCreatedCollection
public void Test_ClearClearsCreatedCollection()
{
//---------------Set up test pack-------------------
ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
ContactPersonTestBO.DeleteAllContactPeople();
CreateTwoSavedContactPeople();
cpCol.CreateBusinessObject();
//---------------Assert Precondition----------------
Assert.AreEqual(1, cpCol.CreatedBusinessObjects.Count);
//---------------Execute Test ----------------------
cpCol.Clear();
//---------------Test Result -----------------------
Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
}
示例9: Test_CreatedBusinessObject_RestoredTwice
public void Test_CreatedBusinessObject_RestoredTwice()
{
//---------------Set up test pack-------------------
//ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
ContactPersonTestBO newCP = cpCol.CreateBusinessObject();
newCP.Surname = TestUtil.GetRandomString();
newCP.CancelEdits();
//---------------Assert Precondition----------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
//---------------Execute Test ----------------------
newCP.CancelEdits();
//---------------Test Result -----------------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
}
示例10: CreateExistingChild
protected static ContactPersonTestBO CreateExistingChild(BusinessObjectCollection<ContactPersonTestBO> cpCol)
{
ContactPersonTestBO existingChildEdited = cpCol.CreateBusinessObject();
existingChildEdited.Surname = TestUtil.GetRandomString();
existingChildEdited.FirstName = TestUtil.GetRandomString();
existingChildEdited.Save();
return existingChildEdited;
}
示例11: CreateCreatedChild
protected static ContactPersonTestBO CreateCreatedChild(BusinessObjectCollection<ContactPersonTestBO> cpCol)
{
ContactPersonTestBO createdChildUnedited = cpCol.CreateBusinessObject();
return createdChildUnedited;
}
示例12: Test_CreateBusinessObject_AlternateClassDef_NoConstructor_ShouldThrowException
public void Test_CreateBusinessObject_AlternateClassDef_NoConstructor_ShouldThrowException()
{
//---------------Set up test pack-------------------
ClassDef classDef = (ClassDef) OrganisationTestBO.LoadDefaultClassDef();
ClassDef alternateClassDef = classDef.Clone();
alternateClassDef.TypeParameter = TestUtil.GetRandomString();
BusinessObjectCollection<OrganisationTestBO> orgCol = new BusinessObjectCollection<OrganisationTestBO>
{ClassDef = alternateClassDef};
//---------------Execute Test ----------------------
try
{
//this should not work because OrganisationTestBO does not have a constructor that takes a ClassDef as parameter
orgCol.CreateBusinessObject();
Assert.Fail("Expected to throw an HabaneroDeveloperException");
}
//---------------Test Result -----------------------
catch (HabaneroDeveloperException ex)
{
StringAssert.Contains("There was a problem creating a Habanero.Test.BO.OrganisationTestBO", ex.Message);
}
}
示例13: Test_CreateBusinessObject_AlternateClassDef
public void Test_CreateBusinessObject_AlternateClassDef()
{
//---------------Set up test pack-------------------
AddressTestBO addressTestBO = new AddressTestBO();
ClassDef classDef = addressTestBO.ClassDef;
ClassDef alternateClassDef = classDef.Clone();
alternateClassDef.TypeParameter = TestUtil.GetRandomString();
BusinessObjectCollection<AddressTestBO> addressCol = new BusinessObjectCollection<AddressTestBO> {ClassDef = alternateClassDef};
//---------------Execute Test ----------------------
//this should work because AddressTestBO has a constructor that takes a ClassDef as parameter
AddressTestBO newCP = addressCol.CreateBusinessObject();
//---------------Test Result -----------------------
Assert.AreEqual(alternateClassDef, newCP.ClassDef);
}
示例14: 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);
}
示例15: Test_CreatedBusinessObject_MarkForDelete_ShouldBeRemovedFromTheCollection
public void Test_CreatedBusinessObject_MarkForDelete_ShouldBeRemovedFromTheCollection()
{
//---------------Set up test pack-------------------
//ContactPersonTestBO.LoadDefaultClassDef();
BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
ContactPersonTestBO newCP = cpCol.CreateBusinessObject();
newCP.Surname = TestUtil.GetRandomString();
//---------------Assert Precondition----------------
AssertOneObjectInCurrentAndCreatedCollection(cpCol);
//---------------Execute Test ----------------------
newCP.MarkForDelete();
//---------------Test Result -----------------------
Assert.AreEqual(0, cpCol.Count);
Assert.IsTrue(newCP.Status.IsDeleted);
}