コード例 #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);
            }
        }
コード例 #2
0
ファイル: TestBOPropInteger.cs プロジェクト: SaberZA/habanero
        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);
            }
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #9
0
ファイル: TestBOPropInteger.cs プロジェクト: SaberZA/habanero
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #13
0
ファイル: TestBOPropInteger.cs プロジェクト: SaberZA/habanero
        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");
        }
コード例 #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");
        }
コード例 #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");
        }
コード例 #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");
        }
コード例 #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);
        }
コード例 #18
0
ファイル: TestBOPropInteger.cs プロジェクト: SaberZA/habanero
        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");
        }
コード例 #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);
        }
コード例 #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");
        }
コード例 #21
0
ファイル: TestBOPropInteger.cs プロジェクト: SaberZA/habanero
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }