ValidateAndLoadXmlSchemaTest updated with new XmlReader

pull/460/merge^2
Buddhika Chathuranga 2020-04-24 09:52:48 +05:30
parent a9b5c50a67
commit 6496b97108
2 changed files with 12 additions and 16 deletions

View File

@ -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)

View File

@ -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);
}
}
}