public void TestLoadFromResource() { DtdLoader loader = new DtdLoader(); string dtd = loader.LoadDtd("class"); Assert.AreNotEqual(0, dtd.Length); Assert.AreNotEqual("#include", dtd.Substring(0, 8)); }
public void TestMethod() { //---------------Set up test pack------------------- DtdLoader loader = new DtdLoader(); string dtd = loader.LoadDtd("ui"); //---------------Assert PreConditions--------------- //---------------Execute Test ---------------------- //---------------Test Result ----------------------- //---------------Tear Down ------------------------- }
public void TestSimpleDtd() { var textFileLoader = Substitute.For <ITextFileLoader>(); textFileLoader.LoadTextFile("class.dtd").Returns(info => new StringReader(dtd1)); var loader = new DtdLoader(textFileLoader, ""); String dtdFileContents = loader.LoadDtd("class"); Assert.AreEqual(dtd1 + Environment.NewLine, dtdFileContents); }
public void TestIncludeDtdTwice() { var textFileLoader = Substitute.For <ITextFileLoader>(); var loader = new DtdLoader(textFileLoader, ""); textFileLoader.LoadTextFile("key.dtd").Returns(info => new StringReader(dtd3)); textFileLoader.LoadTextFile("class.dtd").Returns(info => new StringReader(dtd1)); textFileLoader.LoadTextFile("property.dtd").Returns(info => new StringReader(dtd2)); String dtdFileContents = loader.LoadDtd("key"); Assert.AreEqual(dtd3processed + Environment.NewLine, dtdFileContents); }
public void TestDtdNotFoundExceptionWithIncludesList() { //---------------Set up test pack------------------- DtdLoader loader = new DtdLoader(new TextFileLoader(), "somepath"); //---------------Execute Test ---------------------- try { string dtd = loader.LoadDtd("somefile", new ArrayList()); Assert.Fail("Expected to throw an FileNotFoundException"); } //---------------Test Result ----------------------- catch (FileNotFoundException ex) { StringAssert.Contains("The Document Type Definition (DTD) file, 'somefile', was not found", ex.Message); } }
public void TestDtdNotFoundExceptionWithEmptyPath() { //---------------Set up test pack------------------- DtdLoader loader = new DtdLoader(new TextFileLoader(), ""); //---------------Execute Test ---------------------- try { string dtd = loader.LoadDtd("notexists"); Assert.Fail("Expected to throw an FileNotFoundException"); } //---------------Test Result ----------------------- catch (FileNotFoundException ex) { StringAssert.Contains("The Document Type Definition (DTD) for the XML element 'notexists' was not found in the application's output/execution directory", ex.Message); } }
public void TestDtdNodeInvalidException() { //---------------Set up test pack------------------- DtdLoader loader = new DtdLoader(); //---------------Execute Test ---------------------- try { string dtd = loader.LoadDtd("notexists"); Assert.Fail("Expected to throw an InvalidXmlDefinitionException"); } //---------------Test Result ----------------------- catch (InvalidXmlDefinitionException ex) { StringAssert.Contains("An invalid node 'notexists' was encountered when loading the class definitions", ex.Message); } }