Ejemplo n.º 1
0
        public void TestLoadFromResource()
        {
            DtdLoader loader = new DtdLoader();
            string    dtd    = loader.LoadDtd("class");

            Assert.AreNotEqual(0, dtd.Length);
            Assert.AreNotEqual("#include", dtd.Substring(0, 8));
        }
Ejemplo n.º 2
0
        public void TestMethod()
        {
            //---------------Set up test pack-------------------
            DtdLoader loader = new DtdLoader();
            string    dtd    = loader.LoadDtd("ui");

            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            //---------------Tear Down -------------------------
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }