Here is a test that demonstrates the issue. I am sure this is a simple
problem but there seems to be very little doco on it.

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NHibernate.Validator;
using NHibernate.Validator.Engine;
using System.Globalization;
using System.Reflection;
using System.Resources;
using NHibernate.Validator.Cfg;
using Environment = NHibernate.Validator.Cfg.Environment;

namespace TestValidator
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestValidator()
        {
            var customer = new Customer();

            ClassValidator classValidator = new
ClassValidator(customer.GetType());
            InvalidValue[] validationMessages =
classValidator.GetInvalidValues(customer);

            Assert.IsTrue(validationMessages.Length == 1);
            Assert.IsTrue(validationMessages[0].Message == "may not be
null or empty");
        }

        [TestMethod]
        public void TestCustomInterpolator()
        {
            ValidatorEngine ve = new ValidatorEngine();
            NHVConfiguration nhvc = new NHVConfiguration();
            nhvc.Properties[Environment.MessageInterpolatorClass] =
typeof(CustomMessageInterpolator).AssemblyQualifiedName;
            ve.Configure(nhvc);

            var customer = new Customer();

            ClassValidator classValidator = new
ClassValidator(customer.GetType());
            InvalidValue[] validationMessages =
classValidator.GetInvalidValues(customer);

            Assert.IsTrue(validationMessages.Length == 1);
            Assert.IsTrue(validationMessages[0].Message ==
"CustomMessageInterpolator");
        }
    }

    public class Customer
    {
        public virtual int CustomerId { get; set; }

        [NotNullNotEmpty]
        public string CustomerName { get; set; }
    }

    public class CustomMessageInterpolator : IMessageInterpolator
    {
        public CustomMessageInterpolator()
        {

        }

        public string Interpolate(string message, IValidator
validator, IMessageInterpolator defaultInterpolator)
        {
            return "CustomMessageInterpolator";
        }
    }
}


On Fri, May 22, 2009 at 11:13 AM, Dario Quintana
<[email protected]> wrote:
> Unique configuration: just set the configuration for NHV in one place. Or
> use app.config Or use nhvalidator.cfg.xml Or programatically (like the
> fluent code you sent me)
> On Thu, May 21, 2009 at 10:01 PM, Craig van Nieuwkerk <[email protected]>
> wrote:
>>
>> What do you mean by a unique configuration? I will create a test on
>> the weekend with a standalone test cases if I can't get it working.
>>
>> Craig.
>>
>
>
>
> --
> Dario Quintana
> http://darioquintana.com.ar
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to