Example #1
0
        public void Can_validate_a_simple_property()
        {
            var cat = new Cat {
                Name = "Beetlejuice", Gender = "F"
            };

            try
            {
                var session = _currentScope.CurrentSession;
                session.SaveOrUpdate(cat);
                Assert.IsFalse(session.GetValidator().IsValid());
                var results = session.GetValidator().GetValidationResults();
                Assert.AreEqual(1, results.Count);
                Assert.AreEqual(1, results[cat].Count);
                Assert.AreEqual(Pet.NameLengthValidation, results[cat][0].ErrorMessage);
                session.GetValidator().Eval(session.Transaction, false);
            }
            finally
            {
                _currentScope.End();
            }
        }