ToString() public method

public ToString ( ) : string
return string
        public void ToStringTest()
        {
            StringWriter  writer    = new StringWriter();
            XmlTextWriter xmlWriter = NiniWriter(writer);

            WriteSection(xmlWriter, "Pets");
            WriteKey(xmlWriter, "cat", "Muffy");
            WriteKey(xmlWriter, "dog", "Rover");
            xmlWriter.WriteEndDocument();
            xmlWriter.Close();

            StringReader    reader    = new StringReader(writer.ToString());
            XmlTextReader   xmlReader = new XmlTextReader(reader);
            XmlConfigSource source    = new XmlConfigSource(xmlReader);

            string eol = Environment.NewLine;

            string compare = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" + eol
                             + "<Nini>" + eol
                             + "  <Section Name=\"Pets\">" + eol
                             + "    <Key Name=\"cat\" Value=\"Muffy\" />" + eol
                             + "    <Key Name=\"dog\" Value=\"Rover\" />" + eol
                             + "  </Section>" + eol
                             + "</Nini>";

            Assert.AreEqual(compare, source.ToString());
        }
示例#2
0
        public void ToStringTest() {
            StringWriter writer = new StringWriter();
            XmlTextWriter xmlWriter = NiniWriter(writer);
            WriteSection(xmlWriter, "Pets");
            WriteKey(xmlWriter, "cat", "Muffy");
            WriteKey(xmlWriter, "dog", "Rover");
            xmlWriter.WriteEndDocument();
            xmlWriter.Close();

            StringReader reader = new StringReader(writer.ToString());
            XmlTextReader xmlReader = new XmlTextReader(reader);
            XmlConfigSource source = new XmlConfigSource(xmlReader);

            string eol = Environment.NewLine;

            string compare = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" + eol
                             + "<Nini>" + eol
                             + "  <Section Name=\"Pets\">" + eol
                             + "    <Key Name=\"cat\" Value=\"Muffy\" />" + eol
                             + "    <Key Name=\"dog\" Value=\"Rover\" />" + eol
                             + "  </Section>" + eol
                             + "</Nini>";
            Assert.AreEqual(compare, source.ToString());
        }