Example #1
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);
            }
        }
Example #2
0
        public void Test_DataMapper_ConvertValueToString_ValidBusinessObject()
        {
            //---------------Set up test pack-------------------
            TestAutoInc.LoadClassDefWithIntID();
            const int    validIntID          = 3;
            const string validvalue          = "ValidValue";
            TestAutoInc  validBusinessObject = new TestAutoInc {
                TestField = validvalue, TestAutoIncID = validIntID
            };

            //---------------Assert Precondition----------------
            Assert.AreEqual(validvalue, validBusinessObject.ToString());
            //---------------Execute Test ----------------------
            string parsedValue = _dataMapper.ConvertValueToString(validBusinessObject);

            //---------------Test Result -----------------------
            Assert.AreEqual(validIntID.ToString(), parsedValue);
        }
Example #3
0
        public void Test_DataMapper_ParsePropValue_ValidBusinessObject()
        {
            //---------------Set up test pack-------------------
            TestAutoInc.LoadClassDefWithIntID();
            const int    validIntID          = 3;
            const string validvalue          = "ValidValue";
            TestAutoInc  validBusinessObject = new TestAutoInc {
                TestField = validvalue, TestAutoIncID = validIntID
            };

            //---------------Assert Precondition----------------
            Assert.AreEqual(validvalue, validBusinessObject.ToString());
            //---------------Execute Test ----------------------
            object parsedValue;
            bool   parsedSucceed = _dataMapper.TryParsePropValue(validBusinessObject, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsNotNull(parsedValue);
            Assert.IsTrue(parsedSucceed);
            Assert.AreEqual(validIntID, parsedValue);
        }
Example #4
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);
     }
 }
 public void Test_DataMapper_ConvertValueToString_ValidBusinessObject()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithIntID();
     const int validIntID = 3;
     const string validvalue = "ValidValue";
     TestAutoInc validBusinessObject = new TestAutoInc {TestField = validvalue, TestAutoIncID = validIntID};
     //---------------Assert Precondition----------------
     Assert.AreEqual(validvalue, validBusinessObject.ToString());
     //---------------Execute Test ----------------------
     string parsedValue = _dataMapper.ConvertValueToString(validBusinessObject);
     //---------------Test Result -----------------------
     Assert.AreEqual(validIntID.ToString(), parsedValue);
 }
 public void Test_DataMapper_ParsePropValue_ValidBusinessObject_ToStringZeroLength()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithIntID();
     const int validIntID = 3;
     const string zeroLengthString = "";
     TestAutoInc validBusinessObject = new TestAutoInc { TestField = zeroLengthString, TestAutoIncID = validIntID };
     //---------------Assert Precondition----------------
     Assert.AreEqual(zeroLengthString, validBusinessObject.ToString());
     Assert.AreEqual("", zeroLengthString);
     //---------------Execute Test ----------------------
     object parsedValue;
     bool parsedSucceed = _dataMapper.TryParsePropValue(validBusinessObject, out parsedValue);
     //---------------Test Result -----------------------
     Assert.IsNotNull(parsedValue);
     Assert.IsTrue(parsedSucceed);
     Assert.AreEqual(validIntID, parsedValue);
 }
 public void Test_PropDef_ParsePropValue_ValidBusinessObject()
 {
     //---------------Set up test pack-------------------
     TestAutoInc.LoadClassDefWithIntID();
     const int validIntID = 3;
     const string validvalue = "ValidValue";
     TestAutoInc validBusinessObject = new TestAutoInc { TestField = validvalue, TestAutoIncID = validIntID };
     //---------------Assert Precondition----------------
     Assert.AreEqual(validvalue, validBusinessObject.ToString());
     //---------------Execute Test ----------------------
     object parsedValue;
     bool parsedSucceed = _propDef.TryParsePropValue(validBusinessObject, out parsedValue);
     //---------------Test Result -----------------------
     Assert.IsNotNull(parsedValue);
     Assert.IsTrue(parsedSucceed);
     Assert.AreEqual(validIntID, parsedValue);
 }