Example #1
0
        private static BOPrimaryKey CreatePrimaryBOKeyGuidAndString()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null)
            {
                ClassDef = ContactPersonTestBO.LoadDefaultClassDef()
            };
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null)
            {
                ClassDef = propDef1.ClassDef
            };
            BOPropCol propCol = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(true));
            propCol.Add(propDef2.CreateBOProp(true));
//            BOPropCol propCol = new BOPropCol();
//            propCol.Add(propDef1.CreateBOProp(true));
//            propCol.Add(propDef2.CreateBOProp(true));
            PrimaryKeyDef keyDef = new PrimaryKeyDef {
                IsGuidObjectID = false
            };

            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            return((BOPrimaryKey)keyDef.CreateBOKey(propCol));
        }
Example #2
0
        public void Test_CreatePrimaryKey_TwoPropDefs()
        {
            //---------------Set up test pack-------------------
            PropDef       propDef1 = new PropDef("prop1", typeof(String), PropReadWriteRule.ReadWrite, null);
            PropDef       propDef2 = new PropDef("prop2", typeof(String), PropReadWriteRule.ReadWrite, null);
            PrimaryKeyDef keyDef   = new PrimaryKeyDef {
                IsGuidObjectID = false
            };

            keyDef.Add(propDef2);
            keyDef.Add(propDef1);

            BOPropCol boPropCol = new BOPropCol();

            boPropCol.Add(propDef1.CreateBOProp(false));
            boPropCol.Add(propDef2.CreateBOProp(false));

            //---------------Assert Precondition----------------
            Assert.AreEqual(2, keyDef.Count);
            //---------------Execute Test ----------------------
            BOPrimaryKey boPrimaryKey = (BOPrimaryKey)keyDef.CreateBOKey(boPropCol);

            //---------------Test Result -----------------------
            Assert.AreEqual(keyDef.Count, boPrimaryKey.Count);
            Assert.IsTrue(boPrimaryKey.IsCompositeKey);
        }
Example #3
0
        public void Setup()
        {
            ClassDef.ClassDefs.Clear();
        	_boPropCol1 = new BOPropCol();
        	_keyDef1 = new KeyDef();
        	_boPropCol2 = new BOPropCol();
        	_keyDef2 = new KeyDef();

            //Props for KeyDef 1
            PropDef lPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);
            _boPropCol1.Add(lPropDef.CreateBOProp(false));
            _keyDef1.Add(lPropDef);

            lPropDef = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            _boPropCol1.Add(lPropDef.CreateBOProp(false));
            _keyDef1.Add(lPropDef);

            //Props for KeyDef 2
            lPropDef = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            _boPropCol2.Add(lPropDef.CreateBOProp(false));
            _keyDef2.Add(lPropDef);

            lPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);
            _boPropCol2.Add(lPropDef.CreateBOProp(false));
            _keyDef2.Add(lPropDef);
        }
Example #4
0
        public void Setup()
        {
            ClassDef.ClassDefs.Clear();
            _boPropCol1 = new BOPropCol();
            _keyDef1    = new KeyDef();
            _boPropCol2 = new BOPropCol();
            _keyDef2    = new KeyDef();

            //Props for KeyDef 1
            PropDef lPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);

            _boPropCol1.Add(lPropDef.CreateBOProp(false));
            _keyDef1.Add(lPropDef);

            lPropDef = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            _boPropCol1.Add(lPropDef.CreateBOProp(false));
            _keyDef1.Add(lPropDef);

            //Props for KeyDef 2
            lPropDef = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            _boPropCol2.Add(lPropDef.CreateBOProp(false));
            _keyDef2.Add(lPropDef);

            lPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);
            _boPropCol2.Add(lPropDef.CreateBOProp(false));
            _keyDef2.Add(lPropDef);
        }
Example #5
0
        public void TestHasAutoIncrementingProperty_TwoProps_True()
        {
            //---------------Set up test pack-------------------
            PropDef propDef1 = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null);

            propDef2.AutoIncrementing = true;
            BOPropCol propCol = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));
            KeyDef keyDef = new KeyDef();

            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            IBOKey boKey = keyDef.CreateBOKey(propCol);

            //---------------Assert PreConditions---------------

            //---------------Execute Test ----------------------
            bool hasAutoIncrementingProperty = boKey.HasAutoIncrementingProperty;

            //---------------Test Result -----------------------

            Assert.IsTrue(hasAutoIncrementingProperty);
            //---------------Tear Down -------------------------
        }
Example #6
0
        public void TestRemove()
        {
            PropDef   propDef = new PropDef("Prop3", typeof(string), PropReadWriteRule.ReadOnly, null);
            BOPropCol propCol = new BOPropCol();

            propCol.Add(propDef.CreateBOProp(false));
            Assert.AreEqual(1, propCol.Count);
            Assert.IsTrue(propCol.Contains("Prop3"), "BOPropCol should contain Prop3 after adding it.");
            propCol.Remove("Prop3");
            Assert.AreEqual(0, propCol.Count, "Remove should remove a BOProp from a BOPropCol");
        }
Example #7
0
        private static BOObjectID CreateBOObjectID()
        {
            PropDef   propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null);
            BOPropCol propCol  = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(false));
            PrimaryKeyDef keyDef = new PrimaryKeyDef();

            keyDef.IsGuidObjectID = true;
            keyDef.Add(propDef1);
            return((BOObjectID)keyDef.CreateBOKey(propCol));
        }
Example #8
0
        private static IBOKey CreateBOKeyGuid()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null)
            {
                ClassDef = ContactPersonTestBO.LoadDefaultClassDef()
            };
            BOPropCol propCol = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(false));
            KeyDef keyDef = new KeyDef {
                propDef1
            };

            return(keyDef.CreateBOKey(propCol));
        }
Example #9
0
        public void init()
        {
            mBOPropCol = new BOPropCol();
            mPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);
            mBOPropCol.Add(mPropDef.CreateBOProp(false));

            mPropDef = new PropDef("Prop2", typeof(string), PropReadWriteRule.ReadWrite, null);
            mPropDef.AddPropRule(new PropRuleString(mPropDef.PropertyName, "Test Message", 1, 10, null));
            mBOPropCol.Add(mPropDef.CreateBOProp(false));

            BOPropCol anotherPropCol = new BOPropCol();
            PropDef anotherPropDef =
                new PropDef("TestAddPropCol", typeof(string), PropReadWriteRule.ReadWrite, null);
            anotherPropCol.Add(anotherPropDef.CreateBOProp(false));

            mBOPropCol.Add(anotherPropCol);
        }
Example #10
0
 public void Test_ValidateProp_WhenPropNotValid_IsValidFalse()
 {
     //---------------Set up test pack-------------------
     //Test compulsory with no default set
     PropDef lPropDefWithRules = new PropDef("PropNameWithRules", "System", "String",
                                             PropReadWriteRule.ReadWrite, null, null, true, false);
     lPropDefWithRules.AddPropRule(new PropRuleString(lPropDefWithRules.PropertyName, "", -1, -1, null));
     IBOProp lBOProp = lPropDefWithRules.CreateBOProp(true);
     //---------------Assert Precondition----------------
     Assert.IsTrue(lBOProp.IsValid);
     Assert.AreEqual("", lBOProp.InvalidReason);
     //---------------Execute Test ----------------------
     lBOProp.Validate();
     //---------------Test Result -----------------------
     Assert.IsFalse(lBOProp.IsValid);
     StringAssert.Contains("'Prop Name With Rules' is a compulsory field and has no value.", lBOProp.InvalidReason);
 }
Example #11
0
        public void init()
        {
            mBOPropCol = new BOPropCol();
            mPropDef   = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);
            mBOPropCol.Add(mPropDef.CreateBOProp(false));

            mPropDef = new PropDef("Prop2", typeof(string), PropReadWriteRule.ReadWrite, null);
            mPropDef.AddPropRule(new PropRuleString(mPropDef.PropertyName, "Test Message", 1, 10, null));
            mBOPropCol.Add(mPropDef.CreateBOProp(false));

            BOPropCol anotherPropCol = new BOPropCol();
            PropDef   anotherPropDef =
                new PropDef("TestAddPropCol", typeof(string), PropReadWriteRule.ReadWrite, null);

            anotherPropCol.Add(anotherPropDef.CreateBOProp(false));

            mBOPropCol.Add(anotherPropCol);
        }
Example #12
0
        public void TestUpdatedEvent()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null);

            BOPropCol propCol = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));

            KeyDef keyDef = new KeyDef {
                propDef1, propDef2
            };
            IBOKey boKey = keyDef.CreateBOKey(propCol);

            boKey.Updated += UpdatedEventHandler;
            propCol["PropName1"].Value = "new value";
            Assert.IsTrue(_updatedEventHandled);
        }
Example #13
0
        public void TestIntegerIndexer()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadOnly, null);
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadOnly, null);

            BOPropCol propCol = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));

            KeyDef keyDef = new KeyDef();

            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            IBOKey boKey = keyDef.CreateBOKey(propCol);

            Assert.AreEqual(propCol["PropName1"], boKey[0]);
            Assert.AreEqual(propCol["PropName2"], boKey[1]);
        }
Example #14
0
        public void TestEquality()
        {
            BOKey boKey = (BOKey)_keyDef1.CreateBOKey(_boPropCol1);

            // Test when property count is different
            KeyDef keyDef   = new KeyDef();
            BOKey  otherKey = new BOKey(keyDef);

            Assert.IsFalse(boKey == otherKey);

            // Same property count, but different prop names
            PropDef   propDef1 = new PropDef("PropName5", typeof(string), PropReadWriteRule.ReadOnly, null);
            PropDef   propDef2 = new PropDef("PropName6", typeof(string), PropReadWriteRule.ReadOnly, null);
            BOPropCol propCol  = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));
            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            otherKey = (BOKey)keyDef.CreateBOKey(propCol);
            Assert.IsFalse(boKey == otherKey);

            // Same props but different values (with one null)
            otherKey = (BOKey)_keyDef1.CreateBOKey(_boPropCol2);
            otherKey["PropName"].Value = "blah";
            Assert.IsFalse(boKey == otherKey);

            // Same props but different values (neither are null)
            otherKey = (BOKey)_keyDef1.CreateBOKey(_boPropCol2);
            boKey["PropName"].Value = "diblah";
            Assert.IsFalse(boKey == otherKey);
            Assert.IsFalse(boKey.Equals(otherKey));

            // False when different type of object
            Assert.IsFalse(boKey.Equals(keyDef));

            // Finally, when they are equal
            boKey["PropName"].Value = "blah";
            Assert.IsTrue(boKey == otherKey);
            Assert.IsTrue(boKey.Equals(otherKey));
        }
Example #15
0
        public void TestDirtyXml()
        {
            mProp = mBOPropCol["Prop2"];
            mProp.InitialiseProp("Prop2-Orig");
            mProp.Value = "Prop2-New";
            Assert.IsTrue(mProp.IsDirty);

            mProp = mBOPropCol["PropName"];
            mProp.InitialiseProp("Propn-Orig");
            mProp.Value = "PropName-new";
            Assert.IsTrue(mProp.IsDirty);

            mPropDef = new PropDef("Prop3", typeof(string), PropReadWriteRule.ReadOnly, null);
            mPropDef.AddPropRule(new PropRuleString(mPropDef.PropertyName, "Test", 1, 40, null));
            mBOPropCol.Add(mPropDef.CreateBOProp(false));
            mProp = mBOPropCol["Prop3"];
            mProp.InitialiseProp("Prop3-new");
            Assert.IsFalse(mProp.IsDirty);
            const string dirtyXml = "<Properties><Prop2><PreviousValue>Prop2-Orig</PreviousValue><NewValue>Prop2-New</NewValue></Prop2><PropName><PreviousValue>Propn-Orig</PreviousValue><NewValue>PropName-new</NewValue></PropName></Properties>";

            Assert.AreEqual(dirtyXml, mBOPropCol.DirtyXml);
        }
Example #16
0
        public void TestCreateBOProp_CorrectPropCreated()
        {            
            //---------------Set up test pack-------------------
            PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null);

            //-----Test PreCondition--------------------------
            Assert.IsFalse(propDef.HasLookupList());

            //---------------Execute Test ----------------------

            IBOProp prop = propDef.CreateBOProp(false);
            //---------------Test Result -----------------------

            Assert.IsInstanceOf(typeof(BOProp), prop);

        }
Example #17
0
 public void TestCreateBOPropWithLookupList_CorrectPropCreated_WithDefaultValue()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null,99);
     Dictionary<string, string> collection = new Dictionary<string, string>();
     SimpleLookupList simpleLookupList = new SimpleLookupList(collection);
     propDef.LookupList = simpleLookupList;
     //-----Test PreCondition--------------------------
     Assert.IsTrue(propDef.HasLookupList());
     //---------------Execute Test ----------------------
     IBOProp prop = propDef.CreateBOProp(true);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(BOPropLookupList), prop);
 }
Example #18
0
        private static BOPrimaryKey CreatePrimaryBOKeyGuidAndString()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null)
                        { ClassDef = ContactPersonTestBO.LoadDefaultClassDef()};
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null) 
                        { ClassDef = propDef1.ClassDef};
            BOPropCol propCol = new BOPropCol();
            propCol.Add(propDef1.CreateBOProp(true));
            propCol.Add(propDef2.CreateBOProp(true));
//            BOPropCol propCol = new BOPropCol();
//            propCol.Add(propDef1.CreateBOProp(true));
//            propCol.Add(propDef2.CreateBOProp(true));
            PrimaryKeyDef keyDef = new PrimaryKeyDef {IsGuidObjectID = false};
            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            return (BOPrimaryKey)keyDef.CreateBOKey(propCol);
        }
Example #19
0
 private static IBOKey CreateBOKeyGuidAndString()
 {
     PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null)
                            {ClassDef = ContactPersonTestBO.LoadDefaultClassDef()};
     PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null)
                            {ClassDef = propDef1.ClassDef};
     BOPropCol propCol = new BOPropCol();
     propCol.Add( propDef1.CreateBOProp(false));
     propCol.Add(propDef2.CreateBOProp(false));
     KeyDef keyDef = new KeyDef {propDef1, propDef2};
     return keyDef.CreateBOKey(propCol);
 }
Example #20
0
 private static IBOProp CreateWriteOnceBoProp(bool isNew, object defaultValue)
 {
     IBOProp boProp;
     PropDef propDef = new PropDef("TestProp", typeof(String),
                                   PropReadWriteRule.WriteOnce, null, defaultValue, true, false);
     boProp = propDef.CreateBOProp(isNew);
     Assert.AreEqual(defaultValue, boProp.Value, "BOProp value should start being the default value");
     boProp.Value = "TestValue";
     Assert.AreEqual("TestValue", boProp.Value, "BOProp value should now have the given value.");
     boProp.Value = "TestValue2";
     Assert.AreEqual("TestValue2", boProp.Value, "BOProp value should now have the given value.");
     boProp.Value = "TestValue3";
     Assert.AreEqual("TestValue3", boProp.Value, "BOProp value should now have the given value.");
     boProp.Value = "TestValue4";
     Assert.AreEqual("TestValue4", boProp.Value, "BOProp value should now have the given value.");
     return boProp;
 }
Example #21
0
        public void TestDisplayNameSetAfterCompulsoryInitialisation()
        {
            PropDef propDef = new PropDef("TestProp", "System", "String",
                                  PropReadWriteRule.ReadWrite, null, null, true, false);
            IBOProp boProp = propDef.CreateBOProp(true);
            boProp.Validate();
            Assert.IsFalse(boProp.InvalidReason.Contains("'TestProp'"));
            Assert.IsTrue(boProp.InvalidReason.Contains("'Test Prop'"));
            Assert.IsFalse(boProp.InvalidReason.Contains("'Test Property'"));

            Assert.IsFalse(boProp.InvalidReason.Contains("'TestProp'"));
        }
Example #22
0
 public void init()
 {
     _propDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);
     _prop = _propDef.CreateBOProp(false);
 }
Example #23
0
        public void TestFromIRelationship_MultipleProps()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            RelKeyDef relKeyDef = new RelKeyDef();
            const string propValue1 = "bob1";
            PropDef boPropDef1 = new PropDef("Prop1", typeof(String), PropReadWriteRule.ReadWrite, propValue1);
            relKeyDef.Add(new RelPropDef(boPropDef1, "RelatedProp1"));
            const string propValue2 = "bob2";
            PropDef boPropDef2 = new PropDef("Prop2", typeof(String), PropReadWriteRule.ReadWrite, propValue2);
            relKeyDef.Add(new RelPropDef(boPropDef2, "RelatedProp2"));
            RelationshipDef reldef =
                new MultipleRelationshipDef("bob", "Habanero.Test", "MyBO", relKeyDef, false, "", DeleteParentAction.DoNothing);
            ContactPersonTestBO.LoadDefaultClassDef();
            ContactPersonTestBO cp = new ContactPersonTestBO();
            BOPropCol col = new BOPropCol();
            col.Add(boPropDef1.CreateBOProp(true));
            col.Add(boPropDef2.CreateBOProp(true));
            IRelationship relationship = reldef.CreateRelationship(cp, col);
            //---------------Assert PreConditions---------------            
            //---------------Execute Test ----------------------
            Criteria criteria = Criteria.FromRelationship(relationship);
            //---------------Test Result -----------------------
            string expectedString = string.Format("(RelatedProp1 = '{0}') AND (RelatedProp2 = '{1}')", propValue1, propValue2);
            StringAssert.AreEqualIgnoringCase(expectedString, criteria.ToString());

            //---------------Tear Down -------------------------          
        }
Example #24
0
        public void TestHasAutoIncrementingProperty_TwoProps_True()
        {
            //---------------Set up test pack-------------------
            PropDef propDef1 = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null);
            propDef2.AutoIncrementing = true;
            BOPropCol propCol = new BOPropCol();
            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));
            KeyDef keyDef = new KeyDef();
            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            IBOKey boKey = keyDef.CreateBOKey(propCol);

            //---------------Assert PreConditions---------------            

            //---------------Execute Test ----------------------
            bool hasAutoIncrementingProperty = boKey.HasAutoIncrementingProperty;
            //---------------Test Result -----------------------

            Assert.IsTrue(hasAutoIncrementingProperty);
            //---------------Tear Down -------------------------          
        }
Example #25
0
        public void TestEquality()
        {
            BOKey boKey = (BOKey) _keyDef1.CreateBOKey(_boPropCol1);

            // Test when property count is different
            KeyDef keyDef = new KeyDef();
            BOKey otherKey = new BOKey(keyDef);
            Assert.IsFalse(boKey == otherKey);

            // Same property count, but different prop names
            PropDef propDef1 = new PropDef("PropName5", typeof(string), PropReadWriteRule.ReadOnly, null);
            PropDef propDef2 = new PropDef("PropName6", typeof(string), PropReadWriteRule.ReadOnly, null);
            BOPropCol propCol = new BOPropCol();
            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));
            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            otherKey = (BOKey) keyDef.CreateBOKey(propCol);
            Assert.IsFalse(boKey == otherKey);

            // Same props but different values (with one null)
            otherKey = (BOKey) _keyDef1.CreateBOKey(_boPropCol2);
            otherKey["PropName"].Value = "blah";
            Assert.IsFalse(boKey == otherKey);

            // Same props but different values (neither are null)
            otherKey = (BOKey) _keyDef1.CreateBOKey(_boPropCol2);
            boKey["PropName"].Value = "diblah";
            Assert.IsFalse(boKey == otherKey);
            Assert.IsFalse(boKey.Equals(otherKey));

            // False when different type of object
            Assert.IsFalse(boKey.Equals(keyDef));

            // Finally, when they are equal
            boKey["PropName"].Value = "blah";
            Assert.IsTrue(boKey == otherKey);
            Assert.IsTrue(boKey.Equals(otherKey));
        }
Example #26
0
        public void TestUpdatedEvent()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null);
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null);

            BOPropCol propCol = new BOPropCol();
            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));

            KeyDef keyDef = new KeyDef {propDef1, propDef2};
            IBOKey boKey = keyDef.CreateBOKey(propCol);

            boKey.Updated += UpdatedEventHandler;
            propCol["PropName1"].Value = "new value";
            Assert.IsTrue(_updatedEventHandled);
        }
Example #27
0
 public void Test_ConstructProp_ForCustomTypeWithATypeConverter_WithDefaultValueString_ShouldConstructWithCorrectValue()
 {
     //---------------Set up test pack-------------------
     const string expectedValue = "*****@*****.**";
     var type = typeof(EmailAddressWithTypeConverter);
     var propDef = new PropDef("Name", type.Assembly.FullName, type.Name, PropReadWriteRule.ReadWrite, "DD", expectedValue, false, false);
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf<EmailAddressWithTypeConverter>(propDef.DefaultValue);
     Assert.AreEqual(expectedValue, propDef.DefaultValue.ToString());
     Assert.AreEqual(expectedValue, propDef.DefaultValueString);
     //---------------Execute Test ----------------------
     var prop = propDef.CreateBOProp(true);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<EmailAddressWithTypeConverter>(prop.Value);
     Assert.AreEqual(expectedValue, prop.Value.ToString());
 }
Example #28
0
 public void Test_RestoreValidPropToInvalidState()
 {
     //---------------Set up test pack-------------------
                 //Test compulsory with no default set
     PropDef lPropDefWithRules = new PropDef("PropNameWithRules", "System", "String",
                                             PropReadWriteRule.ReadWrite, null, null, true, false);
     lPropDefWithRules.AddPropRule(new PropRuleString(lPropDefWithRules.PropertyName, "", -1, -1, null));
     IBOProp lBOProp = lPropDefWithRules.CreateBOProp(true);
     //Do validate
     lBOProp.Validate(); 
     lBOProp.Value = "New Value";
     //---------------Assert Precondition----------------
     Assert.IsTrue(lBOProp.IsValid);
     Assert.IsFalse(lBOProp.InvalidReason.Length > 0);
     //---------------Execute Test ----------------------
     lBOProp.RestorePropValue();
     //---------------Test Result -----------------------
     Assert.IsFalse(lBOProp.IsValid);
     Assert.IsTrue(lBOProp.InvalidReason.Length > 0);
 }
Example #29
0
 public void TestRemove()
 {
     PropDef propDef = new PropDef("Prop3", typeof(string), PropReadWriteRule.ReadOnly, null);
     BOPropCol propCol = new BOPropCol();
     propCol.Add(propDef.CreateBOProp(false));
     Assert.AreEqual(1, propCol.Count);
     Assert.IsTrue(propCol.Contains("Prop3"), "BOPropCol should contain Prop3 after adding it.");
     propCol.Remove("Prop3");
     Assert.AreEqual(0, propCol.Count, "Remove should remove a BOProp from a BOPropCol");
 }
Example #30
0
 public void TestPropBrokenRuleRestore()
 {
     //Test compulsory with no default set
     PropDef lPropDefWithRules = new PropDef("PropNameWithRules", typeof(string),
                                             PropReadWriteRule.ReadWrite, null);
     lPropDefWithRules.AddPropRule( new PropRuleString(lPropDefWithRules.PropertyName, "", 50, 51, null));
     IBOProp lBOProp = lPropDefWithRules.CreateBOProp(true);
     Assert.IsTrue(lBOProp.IsValid);
     try
     {
         lBOProp.Value = "New Value";
     }
     catch (InvalidPropertyValueException)
     {
         //do nothing
     }
     Assert.IsFalse(lBOProp.IsValid);
     lBOProp.RestorePropValue();
     Assert.IsTrue(lBOProp.IsValid);
 }
Example #31
0
 public void TestUpdateProp_WriteNew_Existing()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDef("TestProp", "System", "String",
                                   PropReadWriteRule.WriteNew, null, null, true, false);
     IBOProp boProp = propDef.CreateBOProp(false);
     //---------------Assert preconditions---------------
     Assert.AreEqual(null, boProp.Value, "BOProp value should start being null");
     //---------------Execute Test ----------------------
     try
     {
         boProp.Value = "TestValue";
         Assert.Fail("Expected to throw an BOPropWriteException");
     }
         //---------------Test Result -----------------------
     catch (BOPropWriteException ex)
     {
         StringAssert.Contains("is not editable since it is set up as WriteNew and the object is not new", ex.Message);
     }
 }
Example #32
0
 public void TestUpdateProp_ReadWrite_Existing()
 {
     PropDef propDef = new PropDef("TestProp", "System", "String",
                           PropReadWriteRule.ReadWrite, null, null, true, false);
     IBOProp boProp = propDef.CreateBOProp(false);
     Assert.AreEqual(null, boProp.Value, "BOProp value should start being null");
     boProp.Value = "TestValue";
     Assert.AreEqual("TestValue", boProp.Value, "BOProp value should now have the given value");
     boProp.BackupPropValue();
     boProp.Value = "TestValue2";
     Assert.AreEqual("TestValue2", boProp.Value, "BOProp value should now have the given value");
 }
Example #33
0
 public void TestBoPropWithEnumCreate()
 {
     PropDef propDef = new PropDef("EnumProp", typeof(ContactPersonTestBO.ContactType), PropReadWriteRule.ReadWrite, ContactPersonTestBO.ContactType.Family);
     //Create the property for a new object (default will be set)
     IBOProp boProp;
     boProp = propDef.CreateBOProp(true);
     Assert.AreEqual(ContactPersonTestBO.ContactType.Family, boProp.Value);
     Assert.AreEqual("Family", boProp.PropertyValueString);
     //Create the property for anexisting object (default will not be set)
     boProp = propDef.CreateBOProp(false);
     Assert.AreEqual(null, boProp.Value);
     Assert.AreEqual("", boProp.PropertyValueString);
 }
Example #34
0
        public void TestDirtyXml()
        {
            mProp = mBOPropCol["Prop2"];
            mProp.InitialiseProp("Prop2-Orig");
            mProp.Value = "Prop2-New";
            Assert.IsTrue(mProp.IsDirty);

            mProp = mBOPropCol["PropName"];
            mProp.InitialiseProp("Propn-Orig");
            mProp.Value = "PropName-new";
            Assert.IsTrue(mProp.IsDirty);

            mPropDef = new PropDef("Prop3", typeof(string), PropReadWriteRule.ReadOnly, null);
            mPropDef.AddPropRule( new PropRuleString(mPropDef.PropertyName, "Test", 1, 40, null));
            mBOPropCol.Add(mPropDef.CreateBOProp(false));
            mProp = mBOPropCol["Prop3"];
            mProp.InitialiseProp("Prop3-new");
            Assert.IsFalse(mProp.IsDirty);
            const string dirtyXml = "<Properties><Prop2><PreviousValue>Prop2-Orig</PreviousValue><NewValue>Prop2-New</NewValue></Prop2><PropName><PreviousValue>Propn-Orig</PreviousValue><NewValue>PropName-new</NewValue></PropName></Properties>";
            Assert.AreEqual(dirtyXml, mBOPropCol.DirtyXml);
        }
Example #35
0
        public void TestIntegerIndexer()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadOnly, null);
            PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadOnly, null);
            
            BOPropCol propCol = new BOPropCol();
            propCol.Add(propDef1.CreateBOProp(false));
            propCol.Add(propDef2.CreateBOProp(false));
            
            KeyDef keyDef = new KeyDef();
            keyDef.Add(propDef1);
            keyDef.Add(propDef2);
            IBOKey boKey = keyDef.CreateBOKey(propCol);

            Assert.AreEqual(propCol["PropName1"], boKey[0]);
            Assert.AreEqual(propCol["PropName2"], boKey[1]);
        }
Example #36
0
 private static IBOProp CreateWriteNotNewBoProp(bool isNew)
 {
     IBOProp boProp;
     PropDef propDef = new PropDef("TestProp", "System", "String",
                                   PropReadWriteRule.WriteNotNew, null, null, true, false);
     boProp = propDef.CreateBOProp(isNew);
     Assert.AreEqual(null, boProp.Value, "BOProp value should start being null");
     return boProp;
 }
Example #37
0
        public void Test_CreatePrimaryKey_OnePropDefs()
        {
            //---------------Set up test pack-------------------
            PropDef propDef1 = new PropDef("prop1", typeof(String), PropReadWriteRule.ReadWrite, null);
            PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false };
            keyDef.Add(propDef1);

            BOPropCol boPropCol = new BOPropCol();
            boPropCol.Add(propDef1.CreateBOProp(false));

            //---------------Assert Precondition----------------
            Assert.AreEqual(1, keyDef.Count);
            //---------------Execute Test ----------------------
            BOPrimaryKey boPrimaryKey = (BOPrimaryKey)keyDef.CreateBOKey(boPropCol);
            //---------------Test Result -----------------------
            Assert.AreEqual(keyDef.Count, boPrimaryKey.Count);
            Assert.IsFalse(boPrimaryKey.IsCompositeKey);
        }
Example #38
0
 public void TestBoPropWithEnumValueChange()
 {
     PropDef propDef = new PropDef("EnumProp", typeof(ContactPersonTestBO.ContactType), PropReadWriteRule.ReadWrite, ContactPersonTestBO.ContactType.Family);
     //Create the property for anexisting object (default will not be set)
     IBOProp boProp = propDef.CreateBOProp(false);
     Assert.AreEqual(null, boProp.Value);
     Assert.AreEqual("", boProp.PropertyValueString);
     boProp.InitialiseProp(ContactPersonTestBO.ContactType.Business);
     Assert.IsFalse(boProp.IsDirty);
     Assert.AreEqual(ContactPersonTestBO.ContactType.Business, boProp.Value);
     Assert.AreEqual("Business", boProp.PropertyValueString);
     boProp.Value = ContactPersonTestBO.ContactType.Friend;
     Assert.IsTrue(boProp.IsDirty);
     Assert.AreEqual(ContactPersonTestBO.ContactType.Friend, boProp.Value);
     Assert.AreEqual("Friend", boProp.PropertyValueString);
     boProp.RestorePropValue();
     Assert.IsFalse(boProp.IsDirty);
     Assert.AreEqual(ContactPersonTestBO.ContactType.Business, boProp.Value);
     Assert.AreEqual("Business", boProp.PropertyValueString);
 }
Example #39
0
        private static BOObjectID CreateBOObjectID()
        {
            PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null);
            BOPropCol propCol = new BOPropCol();

            propCol.Add(propDef1.CreateBOProp(false));
            PrimaryKeyDef keyDef = new PrimaryKeyDef();
            keyDef.IsGuidObjectID = true;
            keyDef.Add(propDef1);
            return (BOObjectID)keyDef.CreateBOKey(propCol);
        }