コード例 #1
0
        public void WhenAssignComponentRelationThenUseHbmCompositeMapKeyElement()
        {
            var keyType = typeof(string);
            var hbmMap = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper = new MapKeyRelation(keyType, hbmMap, hbmMapping);
            mapper.Component(mkm => { });

            hbmMap.Item.Should().Be.OfType<HbmCompositeMapKey>();
        }
コード例 #2
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");
        }
コード例 #3
0
        public void WhenAssignComponentRelationThenCallActionWithNotNullParameter()
        {
            var keyType = typeof(string);
            var hbmMap = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper = new MapKeyRelation(keyType, hbmMap, hbmMapping);
            var called = false;
            mapper.Component(mkm =>
            {
                called = true;
                mkm.Should().Not.Be.Null();
            });

            called.Should().Be.True();
        }
コード例 #4
0
        public void WhenAssignComponentRelationThenActionShouldReuseSameInstanceOfMapper()
        {
            var keyType = typeof(string);
            var hbmMap = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper = new MapKeyRelation(keyType, hbmMap, hbmMapping);
            IComponentMapKeyMapper parameterCall1 = null;
            IComponentMapKeyMapper parameterCall2 = null;
            mapper.Component(mkm =>
            {
                parameterCall1 = mkm;
            });
            mapper.Component(mkm =>
            {
                parameterCall2 = mkm;
            });

            parameterCall1.Should().Be.SameInstanceAs(parameterCall2);
        }
コード例 #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");
        }
コード例 #6
0
        public void WhenAssignManyToManyRelationThenUseHbmMapKeyManyToManyElement()
        {
            var keyType = typeof(string);
            var hbmMap = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper = new MapKeyRelation(keyType, hbmMap, hbmMapping);
            mapper.ManyToMany(mkm => { });

            hbmMap.Item.Should().Be.OfType<HbmMapKeyManyToMany>();
        }
コード例 #7
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");
        }
コード例 #8
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");
        }