本文整理汇总了C#中ContactPersonTestBO.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ContactPersonTestBO.Save方法的具体用法?C# ContactPersonTestBO.Save怎么用?C# ContactPersonTestBO.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactPersonTestBO
的用法示例。
在下文中一共展示了ContactPersonTestBO.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateContactPersonTestBO
private static ContactPersonTestBO CreateContactPersonTestBO()
{
ContactPersonTestBO bo = new ContactPersonTestBO();
string newSurname = Guid.NewGuid().ToString();
bo.Surname = newSurname;
bo.Save();
return bo;
}
示例2: Test_SetToNull
public void Test_SetToNull()
{
//---------------Set up test pack-------------------
OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
SingleRelationship<ContactPersonTestBO> relationship = GetAssociationRelationship(organisationTestBO);
relationship.OwningBOHasForeignKey = false;
ContactPersonTestBO contactPerson = new ContactPersonTestBO();
contactPerson.Surname = TestUtil.GetRandomString();
contactPerson.FirstName = TestUtil.GetRandomString();
contactPerson.Organisation = organisationTestBO;
contactPerson.Save();
//---------------Assert Precondition----------------
Assert.AreSame(contactPerson, organisationTestBO.ContactPerson);
//---------------Execute Test ----------------------
organisationTestBO.ContactPerson = null;
//---------------Test Result -----------------------
Assert.IsNull(organisationTestBO.ContactPerson);
}
示例3: Test_ConcurrentSave
public void Test_ConcurrentSave()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
var classDef = ContactPersonTestBO.LoadDefaultClassDef();
FixtureEnvironment.ClearBusinessObjectManager();
TestUtil.WaitForGC();
//---------------Assert Precondition----------------
//---------------Execute Test ----------------------
Parallel.For(0, 1000, i =>
{
var person = new ContactPersonTestBO();
person.Surname = RandomValueGen.GetRandomString(1, 10);
person.Save();
});
//---------------Test Result -----------------------
}
示例4: ShouldMapValuesToCorrectType_WhenPropertyIsNotStringAndDatabaseTypeIs
public void ShouldMapValuesToCorrectType_WhenPropertyIsNotStringAndDatabaseTypeIs()
{
//---------------Set up test pack-------------------
var classDef = ContactPersonTestBO.LoadDefaultClassDef();
classDef.PropDefcol["FirstName"].PropertyType = typeof(int);
var cp1 = new ContactPersonTestBO();
cp1.Surname = Guid.NewGuid().ToString("N");
var firstNameValue = 20;
cp1.SetPropertyValue("FirstName", firstNameValue);
cp1.Save();
var selectQuery = QueryBuilder.CreateSelectQuery(classDef);
selectQuery.Fields.Clear();
selectQuery.Fields.Add("FirstName", QueryBuilder.CreateQueryField(classDef, "FirstName"));
//---------------Execute Test ----------------------
var resultSet = _queryResultLoader.GetResultSet(selectQuery);
//---------------Test Result -----------------------
var rows = resultSet.Rows.ToList();
Assert.AreEqual(firstNameValue, rows[0].Values[0]);
}
示例5: Test_SavedObject_Twice_AddedToObjectManager_Once
public void Test_SavedObject_Twice_AddedToObjectManager_Once()
{
//---------------Set up test pack-------------------
SetupDefaultContactPersonBO();
var boMan = BusinessObjectManager.Instance;
var cp = new ContactPersonTestBO {Surname = TestUtil.GetRandomString()};
cp.Save();
//---------------Assert Precondition----------------
Assert.AreEqual(1, boMan.Count);
Assert.IsTrue(boMan.Contains(cp));
//---------------Execute Test ----------------------
cp.Surname = TestUtil.GetRandomString();
cp.Save();
//---------------Test Result -----------------------
Assert.AreEqual(1, boMan.Count);
Assert.IsTrue(boMan.Contains(cp));
Assert.IsTrue(boMan.Contains(cp.ID));
Assert.IsTrue(boMan.Contains(cp.ID.ObjectID));
//Assert.AreSame(cp, boMan[cp.ID.AsString_CurrentValue()]);
Assert.AreSame(cp, boMan[cp.ID.ObjectID]);
Assert.AreSame(cp, boMan[cp.ID]);
}
示例6: Test_SavedObjectInObjectManager
public void Test_SavedObjectInObjectManager()
{
//---------------Set up test pack-------------------
FixtureEnvironment.ClearBusinessObjectManager();
SetupDefaultContactPersonBO();
var contactPersonTestBO = new ContactPersonTestBO {Surname = TestUtil.GetRandomString()};
//---------------Assert Precondition----------------
Assert.IsTrue(contactPersonTestBO.Status.IsNew);
Assert.AreEqual(1, BusinessObjectManager.Instance.Count);
Assert.IsTrue(BusinessObjectManager.Instance.Contains(contactPersonTestBO));
//---------------Execute Test ----------------------
contactPersonTestBO.Save();
//---------------Test Result -----------------------
Assert.IsFalse(contactPersonTestBO.Status.IsNew);
Assert.AreEqual(1, BusinessObjectManager.Instance.Count);
Assert.IsTrue(BusinessObjectManager.Instance.Contains(contactPersonTestBO));
Assert.IsTrue(BusinessObjectManager.Instance.Contains(contactPersonTestBO.ID));
}
示例7: TestFindAll_UsingClassDef
public void TestFindAll_UsingClassDef()
{
//---------------Set up test pack-------------------
BORegistry.DataAccessor = new DataAccessorInMemory(new DataStoreInMemory());
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef();
OrganisationTestBO.LoadDefaultClassDef();
DataStoreInMemory dataStore = new DataStoreInMemory();
DateTime now = DateTime.Now;
ContactPersonTestBO cp1 = new ContactPersonTestBO();
cp1.DateOfBirth = now;
cp1.Surname = TestUtil.GetRandomString();
cp1.Save();
dataStore.Add(cp1);
ContactPersonTestBO cp2 = new ContactPersonTestBO();
cp2.DateOfBirth = now;
cp2.Surname = TestUtil.GetRandomString();
cp2.Save();
dataStore.Add(cp2);
Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now);
dataStore.Add(OrganisationTestBO.CreateSavedOrganisation());
//---------------Execute Test ----------------------
IBusinessObjectCollection col = dataStore.FindAll(ClassDef.Get<ContactPersonTestBO>(), criteria);
//---------------Test Result -----------------------
Assert.AreEqual(2, col.Count);
Assert.Contains(cp1, col);
Assert.Contains(cp2, col);
}
示例8: TestFind_UsingGuidCriteria_Untyped
public void TestFind_UsingGuidCriteria_Untyped()
{
//---------------Set up test pack-------------------
BORegistry.DataAccessor = new DataAccessorInMemory(new DataStoreInMemory());
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef_WOrganisationID();
OrganisationTestBO.LoadDefaultClassDef();
ContactPersonTestBO cp = new ContactPersonTestBO {Surname = Guid.NewGuid().ToString("N")};
cp.OrganisationID = OrganisationTestBO.CreateSavedOrganisation().OrganisationID;
cp.Save();
DataStoreInMemory dataStore = new DataStoreInMemory();
dataStore.Add(cp);
Criteria criteria = new Criteria("OrganisationID", Criteria.ComparisonOp.Equals, cp.OrganisationID);
//---------------Execute Test ----------------------
ContactPersonTestBO loadedCP = (ContactPersonTestBO) dataStore.Find(typeof(ContactPersonTestBO), criteria);
//---------------Test Result -----------------------
Assert.AreSame(cp.ID, loadedCP.ID);
}
示例9: TestBOLookupListWithString
public void TestBOLookupListWithString()
{
//ContactPersonTestBO.CreateSampleData();
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef();
var classDef = MyBO.LoadClassDefWithBOStringLookup();
//var criteria = new Criteria("Surname", Criteria.ComparisonOp.Equals, "abc");
//var cp =
// BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<ContactPersonTestBO>(criteria);
var cp = new ContactPersonTestBO();
const string expectedSurname = "abc";
cp.Surname = expectedSurname;
cp.Save();
var bo = (BusinessObject) classDef.CreateNewBusinessObject();
bo.SetPropertyValue("TestProp2", "abc");
Assert.IsNotNull(cp, "ContactPerson should not be null");
Assert.AreEqual(cp.ContactPersonID.ToString(), bo.GetPropertyValue("TestProp2"));
Assert.AreEqual("abc", bo.GetPropertyValueToDisplay("TestProp2"));
}
示例10: TestNotIsMatch_OneProp_NotIn_Null
public void TestNotIsMatch_OneProp_NotIn_Null()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef();
ContactPersonTestBO cp = new ContactPersonTestBO();
cp.Surname = "Surname1";
cp.FirstName = null;
cp.Save();
object[] values = new object[] { null, "FirstName1" };
Criteria.CriteriaValues criteriaValues = new Criteria.CriteriaValues(values);
//---------------Assert PreConditions---------------
//---------------Execute Test ----------------------
Criteria criteria = new Criteria("FirstName", Criteria.ComparisonOp.NotIn, criteriaValues);
bool isMatch = criteria.IsMatch(cp);
//---------------Test Result -----------------------
Assert.IsFalse(isMatch, "The object should not be a match since it doesn't match the criteria given.");
//---------------Tear Down -------------------------
}
示例11: TestIsMatch_OneProp_In
public void TestIsMatch_OneProp_In()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef();
ContactPersonTestBO cp = new ContactPersonTestBO();
cp.Surname = "Surname1";
cp.Save();
object[] values = new object[] { "Surname1", "Surname2" };
Criteria.CriteriaValues criteriaValues = new Criteria.CriteriaValues(values);
//---------------Assert PreConditions---------------
//---------------Execute Test ----------------------
Criteria criteria = new Criteria("Surname", Criteria.ComparisonOp.In, criteriaValues);
bool isMatch = criteria.IsMatch(cp);
//---------------Test Result -----------------------
Assert.IsTrue(isMatch, "The object should be a match since it matches the criteria given.");
//---------------Tear Down -------------------------
}
示例12: TestNotIsMatch_OneProp_IS
public void TestNotIsMatch_OneProp_IS()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef();
ContactPersonTestBO cp = new ContactPersonTestBO();
cp.Surname = "MyValue";
cp.Save();
//---------------Assert PreConditions---------------
//---------------Execute Test ----------------------
Criteria criteria = new Criteria("Surname", Criteria.ComparisonOp.Is, "NULL");
bool isMatch = criteria.IsMatch(cp);
//---------------Test Result -----------------------
Assert.IsFalse(isMatch, "The object should not be a match since its surname is not null.");
}
示例13: TestIsMatch_NotLike_Incomparable
public void TestIsMatch_NotLike_Incomparable()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadClassDefWithImageProperty();
ContactPersonTestBO cp = new ContactPersonTestBO();
cp.SetPropertyValue("Image", new System.Drawing.Bitmap(10, 10));
Criteria nameCriteria = new Criteria("Image", Criteria.ComparisonOp.NotLike, new System.Drawing.Bitmap(20, 20));
cp.Surname = TestUtil.GetRandomString();
cp.Save();
//---------------Assert PreConditions---------------
//---------------Execute Test ----------------------
try
{
nameCriteria.IsMatch(cp);
Assert.Fail("expected InvalidOperationException because you Bitmap does not implement IComparable");
//---------------Test Result -----------------------
}
catch (InvalidOperationException ex)
{
StringAssert.Contains("does not implement IComparable and cannot be matched", ex.Message);
}
}
示例14: TestNotIsMatch_OneProp_NotLike_ValuesEndsWith_CriteriaEndsWith
public void TestNotIsMatch_OneProp_NotLike_ValuesEndsWith_CriteriaEndsWith()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef();
ContactPersonTestBO cp = new ContactPersonTestBO();
cp.Surname = "surname is MyValue";
cp.Save();
//---------------Assert PreConditions---------------
//---------------Execute Test ----------------------
Criteria criteria = new Criteria("Surname", Criteria.ComparisonOp.NotLike, "%MyValue");
bool isMatch = criteria.IsMatch(cp);
//---------------Test Result -----------------------
Assert.IsFalse(isMatch, "The object should not be a match since it matches the criteria given.");
}
示例15: TestIsMatch_OneProp_Like_ValuesIdentical_CriteriaEndsWith
public void TestIsMatch_OneProp_Like_ValuesIdentical_CriteriaEndsWith()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
ContactPersonTestBO.LoadDefaultClassDef();
ContactPersonTestBO cp = new ContactPersonTestBO();
cp.Surname = "MyValue";
cp.Save();
//---------------Assert PreConditions---------------
//---------------Execute Test ----------------------
Criteria criteria = new Criteria("Surname", Criteria.ComparisonOp.Like, "%MyValue");
bool isMatch = criteria.IsMatch(cp);
//---------------Test Result -----------------------
Assert.IsTrue(isMatch, "The object should be a match since surname ends with MyValue.");
//---------------Tear Down -------------------------
}