InitialiseProp() публичный Метод

Initialises the property with the specified value
public InitialiseProp ( object propValue ) : bool
propValue object The value to assign
Результат bool
Пример #1
0
 public void Test_InitialiseProp_NullValue()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(null);
     //---------------Test Result -----------------------
     Assert.IsNull(boProp.Value);
 }
Пример #2
0
// ReSharper disable InconsistentNaming
        public void Test_InitialiseProp_NullValue()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            //---------------Assert Precondition----------------
            Assert.AreEqual(typeof (string), boProp.PropertyType);
            Assert.IsNull(boProp.Value);
            //---------------Execute Test ----------------------
            boProp.InitialiseProp(null);
            //---------------Test Result -----------------------
            Assert.IsNull(boProp.Value);
        }
Пример #3
0
 public void Test_InitialiseProp_ValidDateTimeTodayString()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp("yesterday");
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(DateTime.Today.AddDays(-1), boProp.Value);
 }
Пример #4
0
 public void Test_InitialiseProp_Valid()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     const string value = "Valid";
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(value);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(value, boProp.Value);
 }
Пример #5
0
 public void Test_InitialiseProp_ValidDateTime()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     DateTime value = DateTime.MinValue.AddDays(1);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(value);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(value, boProp.Value);
 }
Пример #6
0
 public void Test_InitialiseProp_ValidInteger()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     Int32 value = TestUtil.GetRandomInt();
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(value);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(value, boProp.Value);
 }
Пример #7
0
 public void Test_InitialiseProp_ValidIntegerString()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     Int32 expectedInteger = TestUtil.GetRandomInt();
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(expectedInteger.ToString("d"));
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(expectedInteger, boProp.Value);
     Assert.IsTrue(boProp.Value is Int32, "Value should be an Integer");
 }
Пример #8
0
 public void Test_InitialiseProp_ValidGuidString_B()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     string expectedString = Guid.NewGuid().ToString("B");
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(expectedString);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(expectedString, boProp.Value);
     Assert.IsTrue(boProp.Value is string, "Value should be a expectedString");
 }
Пример #9
0
 public void Test_InitialiseProp_ValidGuid()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     Guid value = Guid.NewGuid();
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(value);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(value, boProp.Value);
     Assert.AreEqual("", boProp.InvalidReason);
     Assert.IsTrue(boProp.IsValid);
 }
Пример #10
0
        public void Test_PropertyValueString_ValidInteger()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            Int32 expectedInteger = TestUtil.GetRandomInt();
            boProp.InitialiseProp(expectedInteger);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(boProp.Value);

            //---------------Execute Test ----------------------
            string propertyValueString = boProp.PropertyValueString;

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedInteger.ToString(), propertyValueString);
        }
Пример #11
0
        public void Test_PropertyValueString_ValidGuid()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            Guid expectedGuid = Guid.NewGuid();
            boProp.InitialiseProp(expectedGuid);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(boProp.Value);

            //---------------Execute Test ----------------------
            string propertyValueString = boProp.PropertyValueString;

            //---------------Test Result -----------------------
            //Assert.AreEqual(expectedGuid.ToString("B").ToUpperInvariant(), propertyValueString);
            Assert.AreEqual(expectedGuid.ToString(), propertyValueString);
        }
Пример #12
0
 public void Test_InitialiseProp_ValidDateTime()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     DateTime expectedDateTime = DateTime.MinValue.AddDays(1);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(expectedDateTime);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(expectedDateTime.ToString(_standardDateTimeFormat), boProp.Value);
     Assert.IsTrue(boProp.Value is string, "Value should be a expectedString");
 }
Пример #13
0
 public void Test_Initialise_InvalidGuidString()
 {
     BOProp boProp = new BOProp(_propDef);
     const string invalid = "Invalid";
     PropDef propDef = (PropDef) boProp.PropDef;
     //---------------Assert Precondition----------------
     Assert.AreEqual(typeof (Guid), propDef.PropertyType);
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     try
     {
         boProp.InitialiseProp(invalid);
         Assert.Fail("expected Err");
     }
         //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         StringAssert.Contains(boProp.PropertyName + " cannot be set to " + invalid, ex.Message);
         StringAssert.Contains("It is not a type of ", ex.Message);
         StringAssert.Contains("Guid", ex.Message);
         Assert.AreEqual(null, boProp.Value);
         Assert.IsTrue(boProp.IsValid);
     }
 }
Пример #14
0
        public void Test_PropertyValueString_Null()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            boProp.InitialiseProp(DBNull.Value);

            //---------------Assert Precondition----------------
            Assert.IsNull(boProp.Value);

            //---------------Execute Test ----------------------
            string propertyValueString = boProp.PropertyValueString;

            //---------------Test Result -----------------------
            Assert.AreEqual("", propertyValueString, "Null persisted prop value should return null string");
        }
Пример #15
0
 public void Test_InialiseProp_DBNUll()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(DBNull.Value);
     //---------------Test Result -----------------------
     Assert.IsNull(boProp.Value);
     Assert.AreEqual("", boProp.InvalidReason);
     Assert.IsTrue(boProp.IsValid);
 }
Пример #16
0
 public void Test_InitialiseProp_InvalidBusinessObject_IDNotGuid()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithAutoIncrementingID();
     BOProp boProp = new BOProp(_propDef);
     //Use auto incrementing because it is the only bo prop that has 
     TestAutoInc bo = new TestAutoInc();
     bo.SetPropertyValue("testautoincid", 1);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     try
     {
         boProp.InitialiseProp(bo);
         Assert.Fail("expected Err");
     }
         //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         StringAssert.Contains(boProp.PropertyName + " cannot be set to " + bo.ToString(), ex.Message);
         StringAssert.Contains("It is not a type of ", ex.Message);
         StringAssert.Contains("Guid", ex.Message);
         Assert.AreEqual(null, boProp.Value);
         Assert.IsTrue(boProp.IsValid);
     }
 }
Пример #17
0
 public void Test_InitialiseProp_ValidBusinessObject()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     MyBO bo = new MyBO();
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(bo);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.IsTrue(boProp.Value is Guid, "Value should be a guid");
     Assert.AreEqual(bo.MyBoID, boProp.Value);
 }
Пример #18
0
 public void Test_InitialiseProp_InValidBusinessObject()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadDefaultClassDef_CompulsoryField_TestProp();
     BOProp boProp = new BOProp(_propDef);
     MyBO bo = new MyBO();
     //bo.SetPropertyValue("MyBoID", null);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(bo);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.IsTrue(boProp.Value is Guid, "Value should be a guid");
     Assert.AreEqual(bo.MyBoID, boProp.Value);
 }
Пример #19
0
 public void Test_InitialiseProp_ValidInt()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     int expectedInt = BOTestUtils.RandomInt;
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(expectedInt);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(expectedInt.ToString(), boProp.Value);
     Assert.IsTrue(boProp.Value is string, "Value should be a expectedString");
 }
Пример #20
0
        public void Test_PropertyValueString_Valid()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            const string expectedString = "Valid";
            boProp.InitialiseProp(expectedString);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(boProp.Value);

            //---------------Execute Test ----------------------
            string propertyValueString = boProp.PropertyValueString;

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedString, propertyValueString);
        }
Пример #21
0
 public void Test_InitialiseProp_EmptyGuidString_B()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     Guid guid = Guid.Empty;
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(guid.ToString("B"));
     //---------------Test Result -----------------------
     Assert.IsNull(boProp.Value);
 }
Пример #22
0
 public void Test_InitialiseProp_WithDecimal_RoundDown()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     const decimal value = 321.49m;
     decimal expectedInteger = Math.Round(value);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(value);
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(expectedInteger, boProp.Value);
     Assert.IsTrue(boProp.Value is Int32, "Value should be an Integer");
 }
Пример #23
0
 public void Test_InitialiseProp_WithDecimal_Max()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     const decimal value = decimal.MaxValue;
     decimal expectedInteger = Math.Round(value);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     try
     {
         boProp.InitialiseProp(value);
         Assert.Fail("expected Err");
     }
     //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         StringAssert.Contains(boProp.PropertyName + " cannot be set to " + value, ex.Message);
         StringAssert.Contains("It is not a type of ", ex.Message);
         StringAssert.Contains("Int32", ex.Message);
         Assert.AreEqual(null, boProp.Value);
         Assert.IsTrue(boProp.IsValid);
     }
 }
Пример #24
0
 public void Test_InitialiseProp_ValidGuidString_B()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     Guid guid = Guid.NewGuid();
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.InitialiseProp(guid.ToString("B"));
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.AreEqual(guid, boProp.Value);
     Assert.IsTrue(boProp.Value is Guid, "Value should be a guid");
     Assert.AreEqual("", boProp.InvalidReason);
     Assert.IsTrue(boProp.IsValid);
 }
Пример #25
0
        public void Test_PropertyValueString_ValidDateTime()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            DateTime expectedDateTime = DateTime.MinValue.AddDays(1);
            boProp.InitialiseProp(expectedDateTime);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(boProp.Value);

            //---------------Execute Test ----------------------
            string propertyValueString = boProp.PropertyValueString;

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedDateTime.ToString(_standardDateTimeFormat), propertyValueString);
        }