本文整理汇总了C#中IClassDef.CreateNewBusinessObject方法的典型用法代码示例。如果您正苦于以下问题:C# IClassDef.CreateNewBusinessObject方法的具体用法?C# IClassDef.CreateNewBusinessObject怎么用?C# IClassDef.CreateNewBusinessObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClassDef
的用法示例。
在下文中一共展示了IClassDef.CreateNewBusinessObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_GetPropertyValueToDisplay_WhenVirtualPropertyValue
public void Test_GetPropertyValueToDisplay_WhenVirtualPropertyValue()
{
ClassDef.ClassDefs.Clear();
_itsClassDef = MyBO.LoadDefaultClassDef();
MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();
BOMapper mapper = new BOMapper(bo1);
Assert.AreEqual("MyNameIsMyBo", mapper.GetPropertyValueToDisplay("-MyName-"));
}
示例2: Test_GetPropertyValue_WithDot
public void Test_GetPropertyValue_WithDot()
{
ClassDef.ClassDefs.Clear();
_itsClassDef = MyBO.LoadClassDefWithRelationship();
_itsRelatedClassDef = MyRelatedBo.LoadClassDef();
//MyBO bo1 = (MyBO)itsClassDef.CreateNewBusinessObject(connection);
MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();
MyRelatedBo relatedBo = (MyRelatedBo)_itsRelatedClassDef.CreateNewBusinessObject();
Guid myRelatedBoGuid = relatedBo.ID.GetAsGuid();
bo1.SetPropertyValue("RelatedID", myRelatedBoGuid);
relatedBo.SetPropertyValue("MyRelatedTestProp", "MyValue");
BOMapper mapper = new BOMapper(bo1);
Assert.AreEqual("MyValue", mapper.GetPropertyValueToDisplay("MyRelationship.MyRelatedTestProp"));
}
示例3: Test_GetPropertyValue_WithDot_IncorrectRelationshipName
public void Test_GetPropertyValue_WithDot_IncorrectRelationshipName()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
_itsClassDef = MyBO.LoadClassDefWithRelationship();
_itsRelatedClassDef = MyRelatedBo.LoadClassDef();
MyBO bo1 = (MyBO) _itsClassDef.CreateNewBusinessObject();
BOMapper mapper = new BOMapper(bo1);
//---------------Execute Test ----------------------
try
{
mapper.GetPropertyValueToDisplay("MyIncorrectRelationship.MyRelatedTestProp");
Assert.Fail("Expected to throw an RelationshipNotFoundException");
}
//---------------Test Result -----------------------
catch (RelationshipNotFoundException ex)
{
StringAssert.Contains("The relationship 'MyIncorrectRelationship' on 'MyBO' cannot be found", ex.Message);
}
}
示例4: Test_SetDisplayPropertyValue_WhenLookupList_ShouldSetUnderlyingValue
public void Test_SetDisplayPropertyValue_WhenLookupList_ShouldSetUnderlyingValue()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
const string propertyName = "TestProp2";
const string expectedLookupDisplayValue = "s1";
Guid expectedLookupValue;
StringUtilities.GuidTryParse("{E6E8DC44-59EA-4e24-8D53-4A43DC2F25E7}", out expectedLookupValue);
_itsClassDef = MyBO.LoadClassDefWithLookup();
MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();
BOMapper boMapper = new BOMapper(bo1);
//---------------Assert Precondition----------------
Assert.IsNullOrEmpty(bo1.TestProp2);
//---------------Execute Test ----------------------
boMapper.SetDisplayPropertyValue(propertyName, expectedLookupDisplayValue);
//---------------Test Result -----------------------
Assert.AreEqual(expectedLookupValue, bo1.GetPropertyValue(propertyName));
Assert.AreEqual(expectedLookupDisplayValue, bo1.GetPropertyValueToDisplay(propertyName));
}
示例5: Test_GetPropertyValueToDisplay_SimpleLookup
public void Test_GetPropertyValueToDisplay_SimpleLookup()
{
ClassDef.ClassDefs.Clear();
_itsClassDef = MyBO.LoadClassDefWithSimpleIntegerLookup();
MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();
bo1.SetPropertyValue("TestProp2", "Text");
BOMapper mapper = new BOMapper(bo1);
Assert.AreEqual("Text", mapper.GetPropertyValueToDisplay("TestProp2"));
}
示例6: GetCol_BO_2Items
private static IBusinessObjectCollection GetCol_BO_2Items(IClassDef classDef)
{
IBusinessObjectCollection col = new BusinessObjectCollection<BusinessObject>(classDef);
IBusinessObject bo1 = classDef.CreateNewBusinessObject();
bo1.SetPropertyValue("TestProp", "Value1");
bo1.SetPropertyValue("TestProp2", "Value2");
IBusinessObject bo2 = classDef.CreateNewBusinessObject();
bo2.SetPropertyValue("TestProp", "2Value1");
bo2.SetPropertyValue("TestProp2", "2Value2");
col.Add(bo1);
col.Add(bo2);
return col;
}
示例7: GetCol_BO_1CheckboxItem
private static IBusinessObjectCollection GetCol_BO_1CheckboxItem(IClassDef classDef)
{
IBusinessObjectCollection col = new BusinessObjectCollection<BusinessObject>(classDef);
IBusinessObject bo1 = classDef.CreateNewBusinessObject();
bo1.SetPropertyValue("TestProp", true);
col.Add(bo1);
return col;
}
示例8: GetCol_BO_1ComboBoxItem
private static IBusinessObjectCollection GetCol_BO_1ComboBoxItem(IClassDef classDef)
{
IBusinessObjectCollection col = new BusinessObjectCollection<BusinessObject>(classDef);
IBusinessObject bo1 = classDef.CreateNewBusinessObject();
bo1.SetPropertyValue("RelatedID", Guid.NewGuid());
col.Add(bo1);
return col;
}
示例9: TestCreateBusinessObject_SetsDefaults
public void TestCreateBusinessObject_SetsDefaults()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
XmlClassLoader loader = new XmlClassLoader(new DtdLoader(), new DefClassFactory());
_classDef =
loader.LoadClass(
@"
<class name=""MyBO"" assembly=""Habanero.Test"">
<property name=""MyBoID"" type=""Guid"" />
<property name=""TestProp"" default=""defaultValue"" />
<primaryKey>
<prop name=""MyBoID"" />
</primaryKey>
</class>
");
ClassDef.ClassDefs.Add(_classDef);
//-------------Assert Preconditions -------------
//---------------Execute Test ----------------------
IBusinessObject bo = _classDef.CreateNewBusinessObject();
//---------------Test Result -----------------------
Assert.IsInstanceOf(typeof(MyBO), bo);
Assert.AreEqual("defaultValue", bo.GetPropertyValue("TestProp"));
}
示例10: TestCreateBusinessObject
public void TestCreateBusinessObject()
{
ClassDef.ClassDefs.Clear();
XmlClassLoader loader = new XmlClassLoader(new DtdLoader(), new DefClassFactory());
_classDef =
loader.LoadClass(
@"
<class name=""MyBO"" assembly=""Habanero.Test"">
<property name=""MyBoID"" type=""Guid"" />
<property name=""TestProp"" />
<primaryKey>
<prop name=""MyBoID"" />
</primaryKey>
</class>
");
ClassDef.ClassDefs.Add(_classDef);
IBusinessObject bo = _classDef.CreateNewBusinessObject();
Assert.AreSame(typeof(MyBO), bo.GetType());
bo.SetPropertyValue("TestProp", "TestValue");
Assert.AreEqual("TestValue", bo.GetPropertyValue("TestProp"));
}