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);
        }
Ejemplo n.º 2
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);
        }
        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);
        }