public void AddStream() { string tmpf = Path.GetTempFileName(); using (StreamWriter sw = new StreamWriter(tmpf)) { sw.WriteLine("<?xml version='1.0' encoding='utf-8' ?>"); sw.WriteLine("<nhv-mapping xmlns='urn:nhibernate-validator-1.0'>"); sw.WriteLine("<class name='Boo'>"); sw.WriteLine("<property name='field'><notnullorempty/></property>"); sw.WriteLine("</class>"); sw.WriteLine("</nhv-mapping>"); sw.Flush(); } XmlMappingLoader ml = new XmlMappingLoader(); using (StreamReader sr = new StreamReader(tmpf)) { ml.AddInputStream(sr.BaseStream, tmpf); } Assert.AreEqual(1, ml.Mappings.Length); }
public void AddWrongStream() { string tmpf = Path.GetTempFileName(); using (StreamWriter sw = new StreamWriter(tmpf)) { sw.WriteLine("<?xml version='1.0' encoding='utf-8' ?>"); sw.WriteLine("<nhv-mapping xmlns='urn:nhibernate-validator-1.0'>"); sw.WriteLine("<no valid node>"); sw.WriteLine("</nhv-mapping>"); sw.Flush(); } XmlMappingLoader ml = new XmlMappingLoader(); using (StreamReader sr = new StreamReader(tmpf)) { ml.AddInputStream(sr.BaseStream, tmpf); } Assert.AreEqual(1, ml.Mappings.Length); }
public void AddWrongStream() { string tmpf = Path.GetTempFileName(); using (StreamWriter sw = new StreamWriter(tmpf)) { sw.WriteLine("<?xml version='1.0' encoding='utf-8' ?>"); sw.WriteLine("<nhv-mapping xmlns='urn:nhibernate-validator-1.0'>"); sw.WriteLine("<no valid node>"); sw.WriteLine("</nhv-mapping>"); sw.Flush(); } XmlMappingLoader ml = new XmlMappingLoader(); using (StreamReader sr = new StreamReader(tmpf)) { ActionAssert.Throws<ValidatorConfigurationException>(() => ml.AddInputStream(sr.BaseStream, tmpf)); } }