Example #1
0
        public void WhenAssignElementRelationThenUseHbmMapKeyElement()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Element(mkm => { });

            hbmMap.Item.Should().Be.OfType <HbmMapKey>();
        }
Example #2
0
        public void WhenAssignElementRelationThenCallActionWithNotNullParameter()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);
            var called     = false;

            mapper.Element(mkm => { called = true;
                                    mkm.Should().Not.Be.Null(); });

            called.Should().Be.True();
        }
Example #3
0
        public void WhenAssignElementRelationThenAssignType()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Element(mkm => { });

            var keyElement = (HbmMapKey)hbmMap.Item;

            keyElement.Type.name.Should().Not.Be.Null();
            keyElement.Type.name.Should().Contain("String");
        }
Example #4
0
        public void WhenAssignComponentRelationThenAssignClass()
        {
            var keyType    = typeof(MyClass);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Component(mkm => { });

            var keyElement = (HbmCompositeMapKey)hbmMap.Item;

            keyElement.Class.Should().Not.Be.Null();
            keyElement.Class.Should().Contain("MyClass");
        }
Example #5
0
        public void WhenAssignElementRelationThenActionShouldReuseSameInstanceOfHbmElement()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Element(mkm => mkm.Column("pizza"));
            mapper.Element(mkm => mkm.Length(30));

            var keyElement = (HbmMapKey)hbmMap.Item;

            keyElement.length.Should().Be("30");
            keyElement.column.Should().Be("pizza");
        }
Example #6
0
        public void WhenAssignManyToManyRelationActionShouldReuseSameInstanceOfHbmElement()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.ManyToMany(mkm => mkm.Column("pizza"));
            mapper.ManyToMany(mkm => mkm.ForeignKey("FK"));

            var keyElement = (HbmMapKeyManyToMany)hbmMap.Item;

            keyElement.foreignkey.Should().Be("FK");
            keyElement.column.Should().Be("pizza");
        }
Example #7
0
        public void WhenAssignElementRelationThenActionShouldReuseSameInstanceOfMapper()
        {
            var           keyType        = typeof(string);
            var           hbmMap         = new HbmMap();
            var           hbmMapping     = new HbmMapping();
            var           mapper         = new MapKeyRelation(keyType, hbmMap, hbmMapping);
            IMapKeyMapper parameterCall1 = null;
            IMapKeyMapper parameterCall2 = null;

            mapper.Element(mkm =>
            {
                parameterCall1 = mkm;
            });
            mapper.Element(mkm =>
            {
                parameterCall2 = mkm;
            });

            parameterCall1.Should().Be.SameInstanceAs(parameterCall2);
        }