mirror of https://github.com/winsw/winsw
ValidateAndLoadXmlSchemaTest updated with new XmlReader
parent
a9b5c50a67
commit
6496b97108
|
@ -67,7 +67,7 @@ namespace winsw
|
|||
|
||||
try
|
||||
{
|
||||
ValidateAndLoadXmlSchema();
|
||||
ValidateAndLoadXmlSchema(GetXMLReader());
|
||||
}
|
||||
catch (XmlException e)
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ namespace winsw
|
|||
this.dom = dom;
|
||||
}
|
||||
|
||||
public void ValidateAndLoadXmlSchema()
|
||||
public void ValidateAndLoadXmlSchema(XmlReader reader)
|
||||
{
|
||||
XmlReaderSettings settings = new XmlReaderSettings();
|
||||
|
||||
|
@ -117,11 +117,13 @@ namespace winsw
|
|||
|
||||
settings.ValidationType = ValidationType.Schema;
|
||||
settings.ValidationEventHandler += new ValidationEventHandler(XmlValidationEventHandler);
|
||||
|
||||
using(XmlReader reader = XmlReader.Create(BasePath + ".xml"))
|
||||
{
|
||||
dom.Load(reader);
|
||||
}
|
||||
|
||||
dom.Load(reader);
|
||||
}
|
||||
|
||||
private XmlReader GetXMLReader()
|
||||
{
|
||||
return XmlReader.Create(BasePath + ".xml");
|
||||
}
|
||||
|
||||
private void XmlValidationEventHandler(object sender, ValidationEventArgs e)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using NUnit.Framework;
|
||||
using winsw;
|
||||
using winsw.Native;
|
||||
|
@ -455,15 +456,8 @@ $@"<service>
|
|||
|
||||
var serviceDescriptor = ServiceDescriptor.FromXML(seedXml);
|
||||
|
||||
try
|
||||
{
|
||||
serviceDescriptor.ValidateAndLoadXmlSchema();
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Assert.Pass();
|
||||
}
|
||||
var reader = XmlReader.Create(new StringReader(seedXml));
|
||||
serviceDescriptor.ValidateAndLoadXmlSchema(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue