Exemplo n.º 1
0
        public void WriteReadXmlAdjacencyGraph()
        {
            StringWriter  sw     = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.Formatting = Formatting.Indented;

            XmlGraphSerializer ser = new XmlGraphSerializer(Graph);

            ser.WriteXml(writer);

            StringReader   sr     = new StringReader(sw.ToString());
            XmlTextReader  reader = new XmlTextReader(sr);
            AdjacencyGraph g      = (AdjacencyGraph)ser.ReadXml(reader);

            ser = new XmlGraphSerializer(g);
            StringWriter swResult = new StringWriter();

            writer            = new XmlTextWriter(swResult);
            writer.Formatting = Formatting.Indented;
            ser.WriteXml(writer);

            Console.WriteLine("------------ original xml ---------------");
            Console.WriteLine(sw.ToString());

            Console.WriteLine("------------ output xml ---------------");
            Console.WriteLine(swResult.ToString());

            XmlAssert.XmlEquals(sw.ToString(), swResult.ToString());
        }
Exemplo n.º 2
0
        public void WriteReadGraphMlAdjacencyGraph()
        {
            StringWriter  sw     = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.Formatting = Formatting.Indented;

            GraphMLGraphSerializer ser = new GraphMLGraphSerializer();

            ser.Serialize(writer, Graph);
            Console.WriteLine("------------- serialized graph -----------------");
            Console.WriteLine(sw.ToString());

            XmlAssert.XmlValid(sw.ToString());

            StringReader  sr     = new StringReader(sw.ToString());
            XmlTextReader reader = new XmlTextReader(sr);

            ser.TypeFromXml = true;
            ISerializableVertexAndEdgeListGraph g = ser.Deserialize(reader);

            ser = new GraphMLGraphSerializer();
            StringWriter swResult = new StringWriter();

            writer            = new XmlTextWriter(swResult);
            writer.Formatting = Formatting.Indented;
            ser.Serialize(writer, g);
            Console.WriteLine("------------- deserialized graph -----------------");
            Console.WriteLine(swResult.ToString());

            XmlAssert.XmlEquals(sw.ToString(), swResult.ToString());
            CheckGraphEqual(Graph, g);
        }
Exemplo n.º 3
0
        public void AssertStringEqualAndIdenticalToSelf()
        {
            string control = _xmlTrueTest;
            string test    = _xmlTrueTest;

            XmlAssert.XmlIdentical(control, test);
            XmlAssert.XmlEquals(control, test);
        }
Exemplo n.º 4
0
        public void AssertStringEqualAndIdenticalToSelf()
        {
            string control = "<assert>true</assert>";
            string test    = "<assert>true</assert>";

            XmlAssert.XmlIdentical(control, test);
            XmlAssert.XmlEquals(control, test);
        }
Exemplo n.º 5
0
 public void XmlEqualsWithXmlDiffFail_WithDiffConfiguration(string optionalDesciption, string expectedMessage)
 {
     try
     {
         XmlAssert.XmlEquals(new XmlDiff(new XmlInput(_xmlTrueTest), new XmlInput(_xmlFalseTest), new DiffConfiguration(optionalDesciption)));
     }
     catch (AssertionException e)
     {
         Assert.AreEqual(true, e.Message.StartsWith(expectedMessage));
     }
 }
Exemplo n.º 6
0
 public void XmlEqualsWithXmlDiffFail_WithNullOptionalDescription()
 {
     try
     {
         XmlAssert.XmlEquals(new XmlDiff(new XmlInput(_xmlTrueTest), new XmlInput(_xmlFalseTest), new DiffConfiguration(null)));
     }
     catch (AssertionException e)
     {
         Assert.AreEqual(true, e.Message.StartsWith("Xml does not match"));
     }
 }
Exemplo n.º 7
0
        [Test] public void AssertXmlEqualsUsesOptionalDescription()
        {
            string description = "Another Optional Description";

            try {
                XmlDiff diff = new XmlDiff(new XmlInput("<a/>"), new XmlInput("<b/>"),
                                           new DiffConfiguration(description));
                XmlAssert.XmlEquals(diff);
            } catch (AssertionException e) {
                Assert.AreEqual(true, e.Message.StartsWith(description));
            }
        }
Exemplo n.º 8
0
 public void XmlEqualsWithXmlDiffFail()
 {
     XmlAssert.XmlEquals(new XmlDiff(new XmlInput(_xmlTrueTest), new XmlInput(_xmlFalseTest)));
 }
Exemplo n.º 9
0
 public void XmlEqualsWithXmlDiff()
 {
     XmlAssert.XmlEquals(new XmlDiff(_xmlTrueTest, _xmlTrueTest));
 }
Exemplo n.º 10
0
 public void XmlEqualsWithXmlInput()
 {
     XmlAssert.XmlEquals(new XmlInput(_xmlTrueTest), new XmlInput(_xmlTrueTest));
 }
Exemplo n.º 11
0
 public void XmlEqualsWithStringFail()
 {
     XmlAssert.XmlEquals(_xmlTrueTest, _xmlFalseTest);
 }
Exemplo n.º 12
0
 public void XmlEqualsWithTextReaderFail()
 {
     XmlAssert.XmlEquals(new StringReader(_xmlTrueTest), new StringReader(_xmlFalseTest));
 }