示例#1
0
        public void Test_Build_With_2RelProps_ShouldCreateRelDefWithTwoProps()
        {
            //---------------Set up test pack-------------------
            string relationshipName = "R" + GetRandomString();
            string propertyName     = "P" + GetRandomString();
            string relatedPropName  = "P" + GetRandomString();
            string propertyName2    = "P" + GetRandomString();
            string relatedPropName2 = "P" + GetRandomString();
            //---------------Assert Precondition----------------

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

            var multipleRelationshipDef = new RelationshipsBuilderStub <Car>().WithMultipleRelationship <Car>(relationshipName)
                                          .WithCompositeRelationshipKey()
                                          .WithRelProp(propertyName, relatedPropName)
                                          .WithRelProp(propertyName2, relatedPropName2)
                                          .EndCompositeRelationshipKey()
                                          .Build();

            //---------------Test Result -----------------------
            Assert.AreEqual(relationshipName, multipleRelationshipDef.RelationshipName);
            Assert.AreEqual(2, multipleRelationshipDef.RelKeyDef.Count);
            IRelPropDef relPropDef = multipleRelationshipDef.RelKeyDef[propertyName];

            Assert.IsNotNull(relPropDef);
            Assert.AreEqual(propertyName, relPropDef.OwnerPropertyName);
            Assert.AreEqual(relatedPropName, relPropDef.RelatedClassPropName);
            relPropDef = multipleRelationshipDef.RelKeyDef[propertyName2];
            Assert.IsNotNull(relPropDef);
            Assert.AreEqual(propertyName2, relPropDef.OwnerPropertyName);
            Assert.AreEqual(relatedPropName2, relPropDef.RelatedClassPropName);
        }
示例#2
0
        public void Test_Build_WithLambdaProp_ShouldSetRelationshipName()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relationshipDef = new RelationshipsBuilderStub <Car>().WithMultipleRelationship(c => c.Drivers)
                                  .WithRelProp(c => c.VehicleID, d => d.CarID)
                                  .Build();

            //---------------Test Result -----------------------
            Assert.AreEqual("Drivers", relationshipDef.RelationshipName);
        }
        public void Test_Build_WithLambdaProp_ShouldSetRelationshipName()
        {
            //---------------Set up test pack-------------------
            var newRelationshipsBuilder = new RelationshipsBuilderStub <Car>();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var newSingleRelationshipDefBuilder = new SingleRelationshipDefBuilder <Car, SteeringWheel>(newRelationshipsBuilder, c => c.SteeringWheel);
            var singleRelationshipDef           = newSingleRelationshipDefBuilder.Build();

            //---------------Test Result -----------------------
            Assert.AreEqual("SteeringWheel", singleRelationshipDef.RelationshipName);
        }
        public void Test_Build_WithLambdaProp_ShouldSetRelationshipProperties()
        {
            //---------------Set up test pack-------------------
            var newSingleRelationshipDefBuilder = new RelationshipsBuilderStub <Car>().WithSingleRelationship(c => c.SteeringWheel).WithRelProp("VehicleID", "CarID");
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var singleRelationshipDef = newSingleRelationshipDefBuilder.Build();


            //---------------Test Result -----------------------
            Assert.AreEqual("SteeringWheel", singleRelationshipDef.RelationshipName);
            var relPropDef = singleRelationshipDef.RelKeyDef["VehicleID"];

            Assert.IsNotNull(relPropDef);
            Assert.AreEqual("VehicleID", relPropDef.OwnerPropertyName);
            Assert.AreEqual("CarID", relPropDef.RelatedClassPropName);
        }
示例#5
0
        public void Test_Build_WithLambdaProp_ShouldSetRelationshipProperties()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relationshipDef = new RelationshipsBuilderStub <Car>().WithMultipleRelationship(c => c.Drivers)
                                  .WithRelProp(c => c.VehicleID, d => d.CarID)
                                  .Build();

            //---------------Test Result -----------------------
            Assert.AreEqual("Drivers", relationshipDef.RelationshipName);
            var relPropDef = relationshipDef.RelKeyDef["VehicleID"];

            Assert.IsNotNull(relPropDef);
            Assert.AreEqual("VehicleID", relPropDef.OwnerPropertyName);
            Assert.AreEqual("CarID", relPropDef.RelatedClassPropName);
        }
示例#6
0
        public void Test_Build_WithRelProp_ShouldCreateRelDefWithOneProp()
        {
            //---------------Set up test pack-------------------
            const string relationshipName = "Drivers";
            const string propertyName     = "VehicleID";
            const string relatedPropName  = "CarID";
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var multipleRelationshipDef      = new RelationshipsBuilderStub <Car>().WithMultipleRelationship(c => c.Drivers).WithRelProp(propertyName, relatedPropName);
            IRelationshipDef relationshipDef = multipleRelationshipDef.Build();


            //---------------Test Result -----------------------
            Assert.AreEqual(relationshipName, relationshipDef.RelationshipName);
            Assert.AreEqual(1, relationshipDef.RelKeyDef.Count);
            IRelPropDef relPropDef = relationshipDef.RelKeyDef[propertyName];

            Assert.IsNotNull(relPropDef);
            Assert.AreEqual(propertyName, relPropDef.OwnerPropertyName);
            Assert.AreEqual(relatedPropName, relPropDef.RelatedClassPropName);
        }
示例#7
0
        public void Test_Build_WithLambdaProp_WithfakeBOs_ShouldSetRelationshipProperties()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------

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

            /* var multipleRelationshipDef = new MultipleRelationshipDefBuilder<FakeBOWithMultipleRel, FakeBOWithSingleRel>()
             *   .WithRelationshipName(rel => rel.MyMultipleRel)
             *   .WithRelProp(car => car.FakeBOWithMultipleRelationshipID, driver => driver.FKID)
             *   .Build();*/

            IRelationshipDef relationshipDef = new RelationshipsBuilderStub <FakeBOWithMultipleRelWithProp>()
                                               .WithMultipleRelationship(c => c.MyMultipleRel)
                                               //.WithRelProp("FakeBOWithMultipleRelationshipID", "MySingleRelationshipID")
                                               .WithRelProp(x => x.FakeBOWithMultipleRelationshipID, n => n.MySingleRelationshipID)
                                               .Build();
            //---------------Test Result -----------------------
            var relPropDef = relationshipDef.RelKeyDef["FakeBOWithMultipleRelationshipID"];

            Assert.IsNotNull(relPropDef);
            Assert.AreEqual("FakeBOWithMultipleRelationshipID", relPropDef.OwnerPropertyName);
            Assert.AreEqual("MySingleRelationshipID", relPropDef.RelatedClassPropName);
        }
        private static SingleRelationshipDefBuilder <Car, SteeringWheel> GetNewSingleRelationshipDefBuilder(Expression <Func <Car, SteeringWheel> > relationshipExpression)
        {
            var newRelationshipsBuilder = new RelationshipsBuilderStub <Car>();

            return(new SingleRelationshipDefBuilder <Car, SteeringWheel>(newRelationshipsBuilder, relationshipExpression));
        }
        private static SingleRelationshipDefBuilder <Car, SteeringWheel> GetNewSingleRelationshipDefBuilder(string relationshipName)
        {
            var newRelationshipsBuilder = new RelationshipsBuilderStub <Car>();

            return(new SingleRelationshipDefBuilder <Car, SteeringWheel>(newRelationshipsBuilder, relationshipName));
        }
 private static SingleRelationshipDefBuilder<Car, SteeringWheel> GetNewSingleRelationshipDefBuilder(Expression<Func<Car, SteeringWheel>> relationshipExpression)
 {
     var newRelationshipsBuilder = new RelationshipsBuilderStub<Car>();
     return new SingleRelationshipDefBuilder<Car, SteeringWheel>(newRelationshipsBuilder, relationshipExpression);
 }
 private static SingleRelationshipDefBuilder<Car, SteeringWheel> GetNewSingleRelationshipDefBuilder(string relationshipName)
 {
     var newRelationshipsBuilder = new RelationshipsBuilderStub<Car>();
     return new SingleRelationshipDefBuilder<Car, SteeringWheel>(newRelationshipsBuilder, relationshipName);
 }
        public void Test_Build_WithLambdaProp_ShouldSetRelationshipProperties()
        {
            //---------------Set up test pack-------------------
            var newSingleRelationshipDefBuilder = new RelationshipsBuilderStub<Car>().WithSingleRelationship(c => c.SteeringWheel).WithRelProp("VehicleID", "CarID");
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var singleRelationshipDef = newSingleRelationshipDefBuilder.Build();


            //---------------Test Result -----------------------
            Assert.AreEqual("SteeringWheel", singleRelationshipDef.RelationshipName);
            var relPropDef = singleRelationshipDef.RelKeyDef["VehicleID"];
            Assert.IsNotNull(relPropDef);
            Assert.AreEqual("VehicleID", relPropDef.OwnerPropertyName);
            Assert.AreEqual("CarID", relPropDef.RelatedClassPropName);
        }
        public void Test_Build_WithLambdaProp_ShouldSetRelationshipName()
        {
            //---------------Set up test pack-------------------
            var newRelationshipsBuilder = new RelationshipsBuilderStub<Car>();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var newSingleRelationshipDefBuilder = new SingleRelationshipDefBuilder<Car, SteeringWheel>(newRelationshipsBuilder,c=> c.SteeringWheel);
            var singleRelationshipDef = newSingleRelationshipDefBuilder.Build();

            //---------------Test Result -----------------------
            Assert.AreEqual("SteeringWheel", singleRelationshipDef.RelationshipName);
        }