当前位置: 首页>>代码示例>>C#>>正文


C# ContactPersonTestBO.SetPropertyValue方法代码示例

本文整理汇总了C#中ContactPersonTestBO.SetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# ContactPersonTestBO.SetPropertyValue方法的具体用法?C# ContactPersonTestBO.SetPropertyValue怎么用?C# ContactPersonTestBO.SetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContactPersonTestBO的用法示例。


在下文中一共展示了ContactPersonTestBO.SetPropertyValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_SetPropertyValue_WithExpression_WhenInvalidProperty

        public void Test_SetPropertyValue_WithExpression_WhenInvalidProperty()
        {
            //---------------Set up test pack-------------------
            SetupDefaultContactPersonBO();
            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
            var firstName = TestUtil.GetRandomString();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                contactPersonTestBO.SetPropertyValue(testBo => testBo.FirstName + "123", firstName);
            }
            //---------------Test Result -----------------------
            catch (Exception ex)
            {
                Assert.IsInstanceOf<ArgumentException>(ex);
                StringAssert.Contains("testBo => (testBo.FirstName + \"123\") is not a valid property on ContactPersonTestBO", ex.Message);
            }
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:20,代码来源:TestBusinessObject.cs

示例2: 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]);
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:19,代码来源:TestQueryResultLoaderInMemory.cs

示例3: Test_SetPropertyValue_WithEnumString_Invalid

        public void Test_SetPropertyValue_WithEnumString_Invalid()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO.LoadDefaultClassDefWithEnum();
            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
            const string newValue = "InvalidOption";
            //-------------Assert Preconditions -------------

            //---------------Execute Test ----------------------
            InvalidPropertyValueException exception = null;
            try
            {
                contactPersonTestBO.SetPropertyValue("ContactType", newValue);
            }
            catch (InvalidPropertyValueException ex)
            {
                exception = ex;
            }
            //---------------Test Result -----------------------
            Assert.IsNotNull(exception, "Expected exception of type InvalidPropertyValueException");
            StringAssert.Contains(
                "An error occurred while attempting to convert the loaded property value of 'ContactType' to its specified type of 'Habanero.Test.BO.ContactPersonTestBO+ContactType'. The property value is 'InvalidOption'. See log for details",
                exception.Message);

//            object value = contactPersonTestBO.GetPropertyValue("ContactType");
//            Assert.IsInstanceOf(typeof (string), value);
//            Assert.AreEqual(newValue, value);
//            IBOProp prop = contactPersonTestBO.Props["ContactType"];
//            Assert.IsFalse(prop.IsValid);
//            StringAssert.Contains(
//                "for property 'Contact Type' is not valid. It is not a type of ContactPersonTestBO+ContactType.",
//                prop.InvalidReason);

            //Habanero.BO.InvalidPropertyValueException: An error occurred while attempting to convert the loaded property value of 'ContactType' to its specified type of 'Habanero.Test.BO.ContactPersonTestBO+ContactType'. The property value is 'InvalidOption'. See log for details
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:35,代码来源:TestBusinessObject.cs

示例4: Test_SetPropertyValue_WithExpression

 public void Test_SetPropertyValue_WithExpression()
 {
     //---------------Set up test pack-------------------
     SetupDefaultContactPersonBO();
     ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
     var firstName = TestUtil.GetRandomString();
     //---------------Assert Precondition----------------
     Assert.IsNullOrEmpty(contactPersonTestBO.FirstName);
     //---------------Execute Test ----------------------
     contactPersonTestBO.SetPropertyValue(bo => bo.FirstName, firstName);
     //---------------Test Result -----------------------
     Assert.AreEqual(firstName, contactPersonTestBO.FirstName);
 }
开发者ID:Chillisoft,项目名称:habanero,代码行数:13,代码来源:TestBusinessObject.cs

示例5: Test_SetPropertyValue_WithDateTimeString_Invalid

 public void Test_SetPropertyValue_WithDateTimeString_Invalid()
 {
     //---------------Set up test pack-------------------
     SetupDefaultContactPersonBO();
     ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
     const string newDateTime = "31/11/2008";
     IBOProp prop = contactPersonTestBO.Props["DateOfBirth"];
     //-------------Assert Preconditions -------------
     Assert.IsNull(prop.Value);
     Assert.IsTrue(prop.IsValid);
     //---------------Execute Test ----------------------
     try
     {
         contactPersonTestBO.SetPropertyValue("DateOfBirth", newDateTime);
         Assert.Fail("expected Err");
     }
         //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         string message = string.Format("{0} cannot be set to {1}. It is not a type of"
                                        , "DateOfBirth", newDateTime);
         StringAssert.Contains(message, ex.Message);
         StringAssert.Contains("DateTime", ex.Message);
         object value = contactPersonTestBO.GetPropertyValue("DateOfBirth");
         Assert.IsNull(value);
         Assert.IsTrue(prop.IsValid);
     }
 }
开发者ID:Chillisoft,项目名称:habanero,代码行数:28,代码来源:TestBusinessObject.cs

示例6: Test_SetPropertyValue_WithEnumString

        public void Test_SetPropertyValue_WithEnumString()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO.LoadDefaultClassDefWithEnum();
            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
            //-------------Assert Preconditions -------------

            //---------------Execute Test ----------------------
            contactPersonTestBO.SetPropertyValue("ContactType", "Business");
            //---------------Test Result -----------------------
            object value = contactPersonTestBO.GetPropertyValue("ContactType");
            Assert.IsInstanceOf(typeof (ContactPersonTestBO.ContactType), value);
            Assert.AreEqual(ContactPersonTestBO.ContactType.Business, value);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:14,代码来源:TestBusinessObject.cs

示例7: Test_SetPropertyValue_WithDateTimeString

 public void Test_SetPropertyValue_WithDateTimeString()
 {
     //---------------Set up test pack-------------------
     SetupDefaultContactPersonBO();
     ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
     DateTime newDateTime = DateTime.Today.Add(new TimeSpan(6, 3, 2));
     //-------------Assert Preconditions -------------
     //---------------Execute Test ----------------------
     contactPersonTestBO.SetPropertyValue("DateOfBirth", newDateTime.ToString());
     //---------------Test Result -----------------------
     object value = contactPersonTestBO.GetPropertyValue("DateOfBirth");
     Assert.IsInstanceOf(typeof (DateTime), value);
     Assert.AreEqual(newDateTime, value);
 }
开发者ID:Chillisoft,项目名称:habanero,代码行数:14,代码来源:TestBusinessObject.cs

示例8: Test_GetPropertyValue_WithExpression_ValueType

        public void Test_GetPropertyValue_WithExpression_ValueType()
        {
            //---------------Set up test pack-------------------
            SetupDefaultContactPersonBO();
            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
            var originalDateTime = DateTime.Today.AddDays(-TestUtil.GetRandomInt(365));
            contactPersonTestBO.SetPropertyValue(bo => bo.DateOfBirth, originalDateTime);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var dateOfBirth = contactPersonTestBO.GetPropertyValue(testBo => testBo.DateOfBirth);
            //---------------Test Result -----------------------
            Assert.AreEqual(originalDateTime, dateOfBirth);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:14,代码来源:TestBusinessObject.cs

示例9: Test_GetPropertyValue_WithExpression

 public void Test_GetPropertyValue_WithExpression()
 {
     //---------------Set up test pack-------------------
     SetupDefaultContactPersonBO();
     ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
     var originalFirstName = TestUtil.GetRandomString();
     contactPersonTestBO.SetPropertyValue(bo => bo.FirstName, originalFirstName);
     //---------------Assert Precondition----------------
     
     //---------------Execute Test ----------------------
     var firstName = contactPersonTestBO.GetPropertyValue(testBo => testBo.FirstName);
     //---------------Test Result -----------------------
     Assert.AreEqual(originalFirstName, firstName);
 }
开发者ID:Chillisoft,项目名称:habanero,代码行数:14,代码来源:TestBusinessObject.cs

示例10: 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);
            }
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:25,代码来源:TestCriteria.cs

示例11: CreateSavedContactPerson

		private static ContactPersonTestBO CreateSavedContactPerson(string surnameValue, int integerPropertyValue)
		{
			ContactPersonTestBO cp = new ContactPersonTestBO();
			cp.Surname = surnameValue;
			cp.SetPropertyValue("IntegerProperty", integerPropertyValue);
			cp.Save();
			return cp;
		}
开发者ID:kevinbosman,项目名称:habanero,代码行数:8,代码来源:TestBusinessObjectLoader_RefreshCollection.cs


注:本文中的ContactPersonTestBO.SetPropertyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。