Пример #1
0
        public void ThrowsOnTooLong()
        {
            PropertyValueException ex = Assert.Throws <PropertyValueException>(() =>
            {
                using (ISession s = OpenSession())
                {
                    StringClass b = new StringClass();
                    b.StringValue = "0123456789a";
                    s.Save(b);
                    s.Flush();
                }
            });

            Assert.That(ex.Message, Iz.EqualTo("Error dehydrating property value for NHibernate.Test.TypesTest.StringClass.StringValue"));
            Assert.That(ex.InnerException, Iz.TypeOf <HibernateException>());
            Assert.That(ex.InnerException.Message, Iz.EqualTo("The length of the string value exceeds the length configured in the mapping."));
        }
        public void NhThrowsOnTooLong()
        {
            int maxStringLength       = 4000;
            PropertyValueException ex = Assert.Throws <PropertyValueException>(() =>
            {
                using (ISession s = OpenSession())
                {
                    StringClass b     = new StringClass();
                    b.LongStringValue = new string('x', maxStringLength + 1);
                    s.Save(b);
                    s.Flush();
                }
            });

            Assert.That(ex.Message, Iz.EqualTo("Error dehydrating property value for NHibernate.Test.TypesTest.StringClass.LongStringValue"));
            Assert.That(ex.InnerException, Iz.TypeOf <HibernateException>());
            Assert.That(ex.InnerException.Message, Iz.EqualTo("The length of the string value exceeds the length configured in the mapping/parameter."));
        }