Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 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 -------------------------
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a business object property collection that mirrors
        /// this one.  The new collection will contain a BOProp object for
        /// each PropDef object in this collection, with that BOProp object
        /// storing an instance of the PropDef object.
        /// </summary>
        /// <param name="isNewObject">Whether the new BOProps in the
        /// collection will be new objects. See PropDef.CreateBOProp
        /// for more info.</param>
        /// <returns>Returns the new BOPropCol object</returns>
        public IBOPropCol CreateBOPropertyCol(bool isNewObject)
        {
            BOPropCol lBOPropertyCol = new BOPropCol();

            foreach (IPropDef lPropDef in this)
            {
                lBOPropertyCol.Add(lPropDef.CreateBOProp(isNewObject));
            }
            return(lBOPropertyCol);
        }
Exemplo n.º 7
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");
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
        public void Test_Criteria_EmptyRelKey()
        {
            //--------------- Set up test pack ------------------
            BOPropCol propCol = new BOPropCol();
            RelKeyDef relKeyDef = new RelKeyDef();
            RelKey relKey = new RelKey(relKeyDef, propCol);
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            Criteria relCriteria = relKey.Criteria;
            //--------------- Test Result -----------------------
            Assert.IsNull(relCriteria);
        }
Exemplo n.º 10
0
        public void Test_Criteria_EmptyRelKey()
        {
            //--------------- Set up test pack ------------------
            BOPropCol propCol   = new BOPropCol();
            RelKeyDef relKeyDef = new RelKeyDef();
            RelKey    relKey    = new RelKey(relKeyDef, propCol);
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            Criteria relCriteria = relKey.Criteria;

            //--------------- Test Result -----------------------
            Assert.IsNull(relCriteria);
        }
Exemplo n.º 11
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));
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        private void ModifyForInheritance(IBOPropCol propsToInclude)
        {
            //Recursively
            //Look at the superclass and if it is single table inheritance then
            // add the discriminator property to the BOPropCol if it doesnt exist
            // and set the value to the this super class' name

            ClassDef classDef = _currentClassDef; //rather than _bo.ClassDef\

            IBOPropCol discriminatorProps = new BOPropCol();

            AddDiscriminatorProperties(classDef, propsToInclude, discriminatorProps);
            foreach (BOProp boProp in discriminatorProps)
            {
                AddPropToInsertStatement(boProp);
            }
        }
        /// <summary>
        /// Builds a collection of properties to include in the insertion,
        /// depending on the inheritance type.
        /// </summary>
        protected virtual IBOPropCol GetPropsToInclude(IClassDef currentClassDef)
        {
            IBOPropCol propsToIncludeTemp = currentClassDef.PropDefcol.CreateBOPropertyCol(true);

            IBOPropCol propsToInclude = new BOPropCol();

            AddPersistableProps(propsToInclude, propsToIncludeTemp);
            
            while (((ClassDef)currentClassDef).IsUsingSingleTableInheritance() ||
                   ((ClassDef)currentClassDef).IsUsingConcreteTableInheritance())
            {
                var boPropertyCol = currentClassDef.SuperClassClassDef.PropDefcol.CreateBOPropertyCol(true);
                AddPersistableProps(propsToInclude, boPropertyCol);
                currentClassDef = currentClassDef.SuperClassClassDef;
            }

            return propsToInclude;
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Builds a collection of properties to include in the insertion,
        /// depending on the inheritance type.
        /// </summary>
        protected virtual IBOPropCol GetPropsToInclude(IClassDef currentClassDef)
        {
            IBOPropCol propsToIncludeTemp = currentClassDef.PropDefcol.CreateBOPropertyCol(true);

            IBOPropCol propsToInclude = new BOPropCol();

            AddPersistableProps(propsToInclude, propsToIncludeTemp);

            while (((ClassDef)currentClassDef).IsUsingSingleTableInheritance() ||
                   ((ClassDef)currentClassDef).IsUsingConcreteTableInheritance())
            {
                var boPropertyCol = currentClassDef.SuperClassClassDef.PropDefcol.CreateBOPropertyCol(true);
                AddPersistableProps(propsToInclude, boPropertyCol);
                currentClassDef = currentClassDef.SuperClassClassDef;
            }

            return(propsToInclude);
        }
Exemplo n.º 17
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]);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
 public void TestCreateRelProp_PropDoesNotExist()
 {
     //-------------Setup Test Pack ------------------
     BOPropCol propCol = new BOPropCol();
     Exception exception = null;
     IRelProp relProp = null;
     //-------------Execute test ---------------------
     try
     {
         relProp = _relPropDef.CreateRelProp(propCol);
     }
     catch (Exception ex)
     {
         exception = ex;
     }
     //-------------Test Result ----------------------
     Assert.IsNotNull(exception, "An error should have been thrown because the prop does not exist.");
     Assert.IsInstanceOf(typeof(InvalidPropertyNameException), exception);
     Assert.IsNull(relProp, "The relProp should not have been created.");
 }
Exemplo n.º 20
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));
        }
Exemplo n.º 21
0
        public void TestCreateRelProp_PropDoesNotExist()
        {
            //-------------Setup Test Pack ------------------
            BOPropCol propCol   = new BOPropCol();
            Exception exception = null;
            IRelProp  relProp   = null;

            //-------------Execute test ---------------------
            try
            {
                relProp = _relPropDef.CreateRelProp(propCol);
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            //-------------Test Result ----------------------
            Assert.IsNotNull(exception, "An error should have been thrown because the prop does not exist.");
            Assert.IsInstanceOf(typeof(InvalidPropertyNameException), exception);
            Assert.IsNull(relProp, "The relProp should not have been created.");
        }
Exemplo n.º 22
0
        ///<summary>
        /// Generate SqlStatementCollection for the Relationsp
        ///</summary>
        ///<param name="relationship"></param>
        ///<param name="relatedBusinessObject"></param>
        ///<returns></returns>
        public IEnumerable <ISqlStatement> GenerateForRelationship(IRelationship relationship, IBusinessObject relatedBusinessObject)
        {
            _statements = new List <ISqlStatement>();
            var     propsToInclude = new BOPropCol();
            IBOProp oneProp        = null;

            foreach (var propDef in relationship.RelationshipDef.RelKeyDef)
            {
                oneProp = relatedBusinessObject.Props[propDef.RelatedClassPropName];
                propsToInclude.Add(oneProp);
            }

            if (oneProp == null)
            {
                return(_statements);
            }
            IClassDef classDef  = relatedBusinessObject.ClassDef;
            string    tableName = classDef.GetTableName(oneProp.PropDef);

            GenerateSingleUpdateStatement(tableName, propsToInclude, false, (ClassDef)classDef);

            return(_statements);
        }
Exemplo n.º 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 -------------------------          
        }
Exemplo n.º 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 -------------------------          
        }
        ///<summary>
        /// Generate SqlStatementCollection for the Relationsp
        ///</summary>
        ///<param name="relationship"></param>
        ///<param name="relatedBusinessObject"></param>
        ///<returns></returns>
        public IEnumerable<ISqlStatement> GenerateForRelationship(IRelationship relationship, IBusinessObject relatedBusinessObject)
        {
            _statements = new List<ISqlStatement>();
            var propsToInclude = new BOPropCol();
            IBOProp oneProp = null;
            foreach (var propDef in relationship.RelationshipDef.RelKeyDef)
            {
                oneProp = relatedBusinessObject.Props[propDef.RelatedClassPropName];
                propsToInclude.Add(oneProp);
            }

            if (oneProp == null) return _statements;
            IClassDef classDef = relatedBusinessObject.ClassDef;
            string tableName = classDef.GetTableName(oneProp.PropDef);
            GenerateSingleUpdateStatement(tableName, propsToInclude, false, (ClassDef) classDef);

            return _statements;
        }
Exemplo n.º 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);
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
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));
        }
Exemplo n.º 30
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");
 }
Exemplo n.º 31
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);
        }
Exemplo n.º 32
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]);
        }
        private void ModifyForInheritance(IBOPropCol propsToInclude)
        {
            //Recursively
            //Look at the superclass and if it is single table inheritance then 
            // add the discriminator property to the BOPropCol if it doesnt exist 
            // and set the value to the this super class' name

            ClassDef classDef = _currentClassDef; //rather than _bo.ClassDef\

            IBOPropCol discriminatorProps = new BOPropCol();
            AddDiscriminatorProperties(classDef, propsToInclude, discriminatorProps);
            foreach (BOProp boProp in discriminatorProps)
            {
                AddPropToInsertStatement(boProp);
            }
        }
Exemplo n.º 34
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);
 }