Example #1
0
        public void WhenSetInvalidTypeThenThrow()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(string), mapping);

            Executing.This(() => mapper.Type(typeof(object), null)).Should().Throw <ArgumentOutOfRangeException>();
            Executing.This(() => mapper.Type(null, null)).Should().Throw <ArgumentNullException>();
        }
Example #2
0
        public void WhenSetInvalidTypeThenThrow()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(string), mapping);

            ActionAssert.Throws <ArgumentOutOfRangeException>(() => mapper.Type(typeof(object), null));
            ActionAssert.Throws <ArgumentNullException>(() => mapper.Type(null, null));
        }
Example #3
0
        public void WhenSetTypeByNotFormalITypeThenSetTypeFullName()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(string), mapping);

            mapper.Type <EnumStringType <MyEnum> >();

            mapping.Type.name.Should().Contain(typeof(EnumStringType <MyEnum>).FullName);
        }
Example #4
0
        public void WhenSetTypeByITypeThenSetTypeName()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(string), mapping);

            mapper.Type(NHibernateUtil.Int64);

            mapping.Type.name.Should().Be.EqualTo("Int64");
        }
        public void WhenSetTypeByICompositeUserTypeThenSetTypeName()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(object), mapping);

            Assert.That(() => mapper.Type <MyCompoType>(), Throws.Nothing);
            Assert.That(mapping.Type.name, Does.Contain(nameof(MyCompoType)));
            Assert.That(mapping.type, Is.Null);
        }
Example #6
0
        public void WhenSetTypeByIUserTypeWithNullParamsThenSetTypeName()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(string), mapping);

            mapper.Type <MyType>(null);

            mapping.Type.name.Should().Contain("MyType");
            mapping.type.Should().Be.Null();
        }
Example #7
0
        public void WhenSetTypeByIUserTypeWithParamsThenSetType()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(string), mapping);

            mapper.Type <MyType>(new { Param1 = "a", Param2 = 12 });

            mapping.type1.Should().Be.Null();
            mapping.Type.name.Should().Contain("MyType");
            mapping.Type.param.Should().Have.Count.EqualTo(2);
            mapping.Type.param.Select(p => p.name).Should().Have.SameValuesAs("Param1", "Param2");
            mapping.Type.param.Select(p => p.GetText()).Should().Have.SameValuesAs("a", "12");
        }
Example #8
0
        public void WhenSetMultiColumnsValuesThenAddColumns()
        {
            var mapping = new HbmElement();
            var mapper  = new ElementMapper(typeof(string), mapping);

            mapper.Type <MyType>();
            mapper.Columns(cm =>
            {
                cm.Name("column1");
                cm.Length(50);
            }, cm =>
            {
                cm.Name("column2");
                cm.SqlType("VARCHAR(10)");
            });
            mapping.Columns.Should().Have.Count.EqualTo(2);
        }
        public void WhenSetTypeByNotFormalITypeThenSetTypeFullName()
        {
            var mapping = new HbmElement();
            var mapper = new ElementMapper(typeof(string), mapping);
            mapper.Type<EnumStringType<MyEnum>>();

            mapping.Type.name.Should().Contain(typeof(EnumStringType<MyEnum>).FullName);
        }
        public void WhenSetTypeByIUserTypeWithParamsThenSetType()
        {
            var mapping = new HbmElement();
            var mapper = new ElementMapper(typeof(string), mapping);
            mapper.Type<MyType>(new { Param1 = "a", Param2 = 12 });

            mapping.type1.Should().Be.Null();
            mapping.Type.name.Should().Contain("MyType");
            mapping.Type.param.Should().Have.Count.EqualTo(2);
            mapping.Type.param.Select(p => p.name).Should().Have.SameValuesAs("Param1", "Param2");
            mapping.Type.param.Select(p => p.GetText()).Should().Have.SameValuesAs("a", "12");
        }
        public void WhenSetTypeByIUserTypeWithNullParamsThenSetTypeName()
        {
            var mapping = new HbmElement();
            var mapper = new ElementMapper(typeof(string), mapping);
            mapper.Type<MyType>(null);

            mapping.Type.name.Should().Contain("MyType");
            mapping.type.Should().Be.Null();
        }
        public void WhenSetTypeByITypeThenSetTypeName()
        {
            var mapping = new HbmElement();
            var mapper = new ElementMapper(typeof(string), mapping);
            mapper.Type(NHibernateUtil.Int64);

            mapping.Type.name.Should().Be.EqualTo("Int64");
        }
 public void WhenSetMultiColumnsValuesThenAddColumns()
 {
     var mapping = new HbmElement();
     var mapper = new ElementMapper(typeof(string), mapping);
     mapper.Type<MyType>();
     mapper.Columns(cm =>
     {
         cm.Name("column1");
         cm.Length(50);
     }, cm =>
     {
         cm.Name("column2");
         cm.SqlType("VARCHAR(10)");
     });
     mapping.Columns.Should().Have.Count.EqualTo(2);
 }
 public void WhenSetInvalidTypeThenThrow()
 {
     var mapping = new HbmElement();
     var mapper = new ElementMapper(typeof(string), mapping);
     ActionAssert.Throws<ArgumentOutOfRangeException>(() => mapper.Type(typeof(object), null));
     ActionAssert.Throws<ArgumentNullException>(() => mapper.Type(null, null));
 }