예제 #1
0
        public void WhenSetInvalidTypeThenThrow()
        {
            var hbmId  = new HbmId();
            var mapper = new IdMapper(null, hbmId);

            Assert.That(() => mapper.Type(typeof(object), null), Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(() => mapper.Type(null, null), Throws.TypeOf <ArgumentNullException>());
        }
예제 #2
0
        public void WhenSetTypeByITypeThenSetTypeName()
        {
            var hbmId  = new HbmId();
            var mapper = new IdMapper(null, hbmId);

            mapper.Type(NHibernateUtil.String);

            Assert.That(hbmId.Type.name, Is.EqualTo("String"));
        }
예제 #3
0
        public void WhenSetTypeByITypeTypeThenSetType()
        {
            var hbmId  = new HbmId();
            var mapper = new IdMapper(null, hbmId);

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

            Assert.That(hbmId.Type.name, Does.Contain(typeof(EnumStringType <MyEnum>).FullName));
            Assert.That(hbmId.type, Is.Null);
        }
예제 #4
0
        public void WhenSetTypeByIUserTypeWithNullParamsThenSetTypeName()
        {
            var hbmId  = new HbmId();
            var mapper = new IdMapper(null, hbmId);

            mapper.Type <MyType>(null);

            Assert.That(hbmId.Type.name, Does.Contain("MyType"));
            Assert.That(hbmId.type, Is.Null);
        }
예제 #5
0
        public void WhenSetTypeByICompositeUserTypeThenSetTypeName()
        {
            var hbmId  = new HbmId();
            var mapper = new IdMapper(null, hbmId);

            mapper.Type <MyCompoType>();

            Assert.That(hbmId.Type.name, Does.Contain("MyCompoType"));
            Assert.That(hbmId.type, Is.Null);
        }
예제 #6
0
        public void WhenSetTypeByIUserTypeWithParamsThenSetType()
        {
            var hbmId  = new HbmId();
            var mapper = new IdMapper(null, hbmId);

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

            Assert.That(hbmId.type1, Is.Null);
            Assert.That(hbmId.Type.name, Does.Contain("MyType"));
            Assert.That(hbmId.Type.param, Has.Length.EqualTo(2));
            Assert.That(hbmId.Type.param.Select(p => p.name), Is.EquivalentTo(new [] { "Param1", "Param2" }));
            Assert.That(hbmId.Type.param.Select(p => p.GetText()), Is.EquivalentTo(new [] { "a", "12" }));
        }