public bool Equals(EquatableTestEdge other)
 {
     if (other is null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(string.Equals(ID, other.ID) &&
            string.Equals(String, other.String) &&
            Int == other.Int &&
            Long == other.Long &&
            Double.Equals(other.Double) &&
            Bool == other.Bool &&
            Float.Equals(other.Float));
 }
        public void GraphMLSerialization_HeaderCheck(bool emitDeclarationOnSerialize, bool emitDeclarationOnDeserialize)
        {
            var graph = new EquatableTestGraph
            {
                String = "graph",
                Int    = 42
            };

            var vertex1 = new EquatableTestVertex("v1")
            {
                StringDefault = "foo",
                String        = "string",
                Int           = 10,
                Long          = 20,
                Float         = 25.0F,
                Double        = 30.0,
                Bool          = true
            };

            var vertex2 = new EquatableTestVertex("v2")
            {
                StringDefault = "bar",
                String        = "string2",
                Int           = 110,
                Long          = 120,
                Float         = 125.0F,
                Double        = 130.0,
                Bool          = true
            };

            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);

            var edge1 = new EquatableTestEdge(vertex1, vertex2, "e_1")
            {
                String = "edge",
                Int    = 90,
                Long   = 100,
                Float  = 25.0F,
                Double = 110.0,
                Bool   = true
            };

            graph.AddEdge(edge1);

            EquatableTestGraph serializedGraph = VerifySerialization(
                graph,
                g =>
            {
                using (var writer = new StringWriter())
                {
                    var settings = new XmlWriterSettings {
                        Indent = true
                    };
                    using (var xmlWriter = XmlWriter.Create(writer, settings))
                    {
                        var serializer = new GraphMLSerializer <EquatableTestVertex, EquatableTestEdge, EquatableTestGraph>
                        {
                            EmitDocumentDeclaration = emitDeclarationOnDeserialize
                        };

                        serializer.Serialize(
                            xmlWriter,
                            g,
                            vertex => vertex.ID,
                            edge => edge.ID);
                    }

                    return(writer.ToString());
                }
            },
                graphml =>
            {
                using (var reader = new StringReader(graphml))
                {
                    var serializer = new GraphMLDeserializer <EquatableTestVertex, EquatableTestEdge, EquatableTestGraph>
                    {
                        EmitDocumentDeclaration = emitDeclarationOnDeserialize
                    };

#if SUPPORTS_XML_DTD_PROCESSING
                    var settings = new XmlReaderSettings
                    {
                        ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings,
                        XmlResolver     = new GraphMLXmlResolver(),
                        DtdProcessing   = DtdProcessing.Ignore
                    };

                    using (var xmlReader = XmlReader.Create(reader, settings))
                    {
#else
                    var xmlReader = new XmlTextReader(reader);
                    {
                        xmlReader.ProhibitDtd = false;
                        xmlReader.XmlResolver = null;
#endif
                        var g = new EquatableTestGraph();
                        serializer.Deserialize(
                            xmlReader,
                            g,
                            id => new EquatableTestVertex(id),
                            (source, target, id) => new EquatableTestEdge(source, target, id));
                        return(g);
                    }
                }
            });

            Assert.IsTrue(
                EquateGraphs.Equate(
                    graph,
                    serializedGraph));
        }