public void AddTypedClassDefinition()
 {
     var ml = new FluentMappingLoader();
     Assert.Throws<ArgumentNullException>(() => ml.AddClassDefinition<AddressValidationDef>(null));
     ml.AddClassDefinition(new AddressValidationDef());
     Assert.That(ml.GetMappings().Count(), Is.EqualTo(1));
 }
        public void AddNameSpace()
        {
            var ml = new FluentMappingLoader();

            ml.AddNameSpace(Assembly.GetExecutingAssembly(), "NHibernate.Validator.Tests.Configuration.Loquacious");
            Assert.That(ml.GetMappings().Count(), Is.GreaterThan(2));
        }
 public void AddAssemblyByName()
 {
     // in this test we only try to load an entirely assembly without check what was load
     var ml = new FluentMappingLoader();
     ml.AddAssembly(Assembly.GetExecutingAssembly().FullName);
     Assert.That(ml.GetMappings().Count(), Is.GreaterThan(1));
 }
        public void AddClassDefinitionByType()
        {
            var ml = new FluentMappingLoader();

            ml.AddClassDefinition <AddressValidationDef, Address>();
            Assert.That(ml.GetMappings().Count(), Is.EqualTo(1));
        }
        public void AddTypedClassDefinition()
        {
            var ml = new FluentMappingLoader();

            Assert.Throws <ArgumentNullException>(() => ml.AddClassDefinition <AddressValidationDef>(null));
            ml.AddClassDefinition(new AddressValidationDef());
            Assert.That(ml.GetMappings().Count(), Is.EqualTo(1));
        }
        public void AddAssemblyByName()
        {
            // in this test we only try to load an entirely assembly without check what was load
            var ml = new FluentMappingLoader();

            ml.AddAssembly(Assembly.GetExecutingAssembly().FullName);
            Assert.That(ml.GetMappings().Count(), Is.GreaterThan(1));
        }
        public void ClassNotFound()
        {
            const string xml    = @"<nhv-configuration xmlns='urn:nhv-configuration-1.0'>
		<mapping assembly='NHibernate.Validator.Tests' resource='Base.Address.nhv.xml'/>
	</nhv-configuration>"    ;
            var          cfgXml = new XmlDocument();

            cfgXml.LoadXml(xml);
            var xtr = new XmlTextReader(xml, XmlNodeType.Document, null);
            var cfg = new XmlConfiguration(xtr);
            var ml  = new FluentMappingLoader();

            Assert.Throws <ValidatorConfigurationException>(() => ml.LoadMappings(cfg.Mappings));
        }
        public void LoadMappingsFromAssembly()
        {
            const string xmlConf =
                @"<nhv-configuration xmlns='urn:nhv-configuration-1.0'>
		<mapping assembly='NHibernate.Validator.Tests'/>
	</nhv-configuration>"    ;
            var cfgXml = new XmlDocument();

            cfgXml.LoadXml(xmlConf);
            var xtr = new XmlTextReader(xmlConf, XmlNodeType.Document, null);
            var cfg = new XmlConfiguration(xtr);
            var ml  = new FluentMappingLoader();

            ml.LoadMappings(cfg.Mappings);

            Assert.That(ml.GetMappings().Count(), Is.GreaterThan(1));             // the mappings of tests are more than 1 ;)
        }
        public void LoadMappingsSpecific()
        {
            const string xmlConf =
                @"<nhv-configuration xmlns='urn:nhv-configuration-1.0'>
		<mapping assembly='NHibernate.Validator.Tests' resource='NHibernate.Validator.Tests.Configuration.Loquacious.AddressValidationDef'/>
		<mapping assembly='NHibernate.Validator.Tests' resource='NHibernate.Validator.Tests.Configuration.Loquacious.BooValidationDef'/>
	</nhv-configuration>"    ;
            var cfgXml = new XmlDocument();

            cfgXml.LoadXml(xmlConf);
            var xtr = new XmlTextReader(xmlConf, XmlNodeType.Document, null);
            var cfg = new XmlConfiguration(xtr);
            var ml  = new FluentMappingLoader();

            ml.LoadMappings(cfg.Mappings);

            Assert.That(ml.GetMappings().Count(), Is.EqualTo(2));
        }
 public void AddNameSpace()
 {
     var ml = new FluentMappingLoader();
     ml.AddNameSpace(Assembly.GetExecutingAssembly(), "NHibernate.Validator.Tests.Configuration.Loquacious");
     Assert.That(ml.GetMappings().Count(), Is.GreaterThan(2));
 }
 public void AddClassDefinitionByType()
 {
     var ml = new FluentMappingLoader();
     ml.AddClassDefinition<AddressValidationDef, Address>();
     Assert.That(ml.GetMappings().Count(), Is.EqualTo(1));
 }
        public void LoadMappingsSpecific()
        {
            const string xmlConf =
                @"<nhv-configuration xmlns='urn:nhv-configuration-1.0'>
            <mapping assembly='NHibernate.Validator.Tests' resource='NHibernate.Validator.Tests.Configuration.Loquacious.AddressValidationDef'/>
            <mapping assembly='NHibernate.Validator.Tests' resource='NHibernate.Validator.Tests.Configuration.Loquacious.BooValidationDef'/>
            </nhv-configuration>";
            var cfgXml = new XmlDocument();
            cfgXml.LoadXml(xmlConf);
            var xtr = new XmlTextReader(xmlConf, XmlNodeType.Document, null);
            var cfg = new XmlConfiguration(xtr);
            var ml = new FluentMappingLoader();
            ml.LoadMappings(cfg.Mappings);

            Assert.That(ml.GetMappings().Count(), Is.EqualTo(2));
        }
 public void ClassNotFound()
 {
     const string xml = @"<nhv-configuration xmlns='urn:nhv-configuration-1.0'>
     <mapping assembly='NHibernate.Validator.Tests' resource='Base.Address.nhv.xml'/>
     </nhv-configuration>";
     var cfgXml = new XmlDocument();
     cfgXml.LoadXml(xml);
     var xtr = new XmlTextReader(xml, XmlNodeType.Document, null);
     var cfg = new XmlConfiguration(xtr);
     var ml = new FluentMappingLoader();
     Assert.Throws<ValidatorConfigurationException>(() => ml.LoadMappings(cfg.Mappings));
 }
        public void AddWrongAssembly()
        {
            var ml = new FluentMappingLoader();

            Assert.Throws <ValidatorConfigurationException>(() => ml.AddAssembly("NoExistAssemblyName"));
        }
        public void LoadMappingsNull()
        {
            var ml = new FluentMappingLoader();

            Assert.Throws <ArgumentNullException>(() => ml.LoadMappings(null));
        }
 public void AddWrongAssembly()
 {
     var ml = new FluentMappingLoader();
     Assert.Throws<ValidatorConfigurationException>(() => ml.AddAssembly("NoExistAssemblyName"));
 }
 public void AddWrongClassDefinition()
 {
     var ml = new FluentMappingLoader();
     Assert.Throws<ValidatorConfigurationException>(() => ml.AddClassDefinition(Assembly.GetExecutingAssembly(), "ClassDefinition"));
 }
 public void LoadMappingsNull()
 {
     var ml = new FluentMappingLoader();
     Assert.Throws<ArgumentNullException>(() => ml.LoadMappings(null));
 }
        public void LoadMappingsFromAssembly()
        {
            const string xmlConf =
                @"<nhv-configuration xmlns='urn:nhv-configuration-1.0'>
            <mapping assembly='NHibernate.Validator.Tests'/>
            </nhv-configuration>";
            var cfgXml = new XmlDocument();
            cfgXml.LoadXml(xmlConf);
            var xtr = new XmlTextReader(xmlConf, XmlNodeType.Document, null);
            var cfg = new XmlConfiguration(xtr);
            var ml = new FluentMappingLoader();
            ml.LoadMappings(cfg.Mappings);

            Assert.That(ml.GetMappings().Count(), Is.GreaterThan(1)); // the mappings of tests are more than 1 ;)
        }
        public void AddWrongClassDefinition()
        {
            var ml = new FluentMappingLoader();

            Assert.Throws <ValidatorConfigurationException>(() => ml.AddClassDefinition(Assembly.GetExecutingAssembly(), "ClassDefinition"));
        }