Ejemplo n.º 1
0
        public void Test_Initialise_InvalidDateTimeString()
        {
            BOProp       boProp  = new BOProp(_propDef);
            const string invalid = "Invalid";
            PropDef      propDef = (PropDef)boProp.PropDef;

            //---------------Assert Precondition----------------
            Assert.AreEqual(typeof(DateTime), 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("DateTime", ex.Message);
                Assert.AreEqual(null, boProp.Value);
                Assert.IsTrue(boProp.IsValid);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void Test_InitialiseProp_NullValue()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);

            //---------------Assert Precondition----------------
            Assert.AreEqual(typeof(DateTime), boProp.PropertyType);
            Assert.IsNull(boProp.Value);
            //---------------Execute Test ----------------------
            boProp.InitialiseProp(null);
            //---------------Test Result -----------------------
            Assert.IsNull(boProp.Value);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public void Test_InialiseProp_EmptyGuid()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);

            //---------------Assert Precondition----------------
            Assert.IsNull(boProp.Value);
            //---------------Execute Test ----------------------
            boProp.InitialiseProp(Guid.Empty);
            //---------------Test Result -----------------------
            Assert.IsNull(boProp.Value);
            Assert.AreEqual("", boProp.InvalidReason);
            Assert.IsTrue(boProp.IsValid);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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");
        }
Ejemplo n.º 14
0
        public void Test_InitialiseProp_ValidGuid()
        {
            //---------------Set up test pack-------------------
            BOProp boProp       = new BOProp(_propDef);
            Guid   expectedGuid = Guid.NewGuid();

            //---------------Assert Precondition----------------
            Assert.IsNull(boProp.Value);
            //---------------Execute Test ----------------------
            boProp.InitialiseProp(expectedGuid);
            //---------------Test Result -----------------------
            Assert.IsNotNull(boProp.Value);
            Assert.AreEqual(expectedGuid.ToString("B").ToUpperInvariant(), boProp.Value);
            Assert.IsTrue(boProp.Value is string, "Value should be a expectedString");
        }
Ejemplo n.º 15
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");
        }
Ejemplo n.º 16
0
        public void Test_InitialiseProp_ValidDateTimeString()
        {
            //---------------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.ToString("d"));
            //---------------Test Result -----------------------
            Assert.IsNotNull(boProp.Value);
            Assert.AreEqual(expectedDateTime, boProp.Value);
            Assert.IsTrue(boProp.Value is DateTime, "Value should be a expectedDateTime");
        }
Ejemplo n.º 17
0
        public void Test_InitialiseProp_ValidGuidString_P()
        {
            //---------------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("P"));
            //---------------Test Result -----------------------
            Assert.IsNotNull(boProp.Value);
            Assert.IsTrue(boProp.Value is Guid, "Value should be a guid");
            Assert.AreEqual(guid, boProp.Value);
        }
Ejemplo n.º 18
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");
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
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");
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
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);
        }