示例#1
0
        public void GraphMLSerializationWithValidation_WriteEdge(
            [NotNull, InstantHandle] Func <TestGraph, string> serializeGraph,
            bool keepIds)
        {
            var graph = new TestGraph
            {
                Bool   = true,
                Double = 1.0,
                Float  = 2.0F,
                Int    = 10,
                Long   = 100,
                String = "foo"
            };

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

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

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

            var edge = new TestEdge(
                vertex1, vertex2,
                "e1",
                "edge",
                90,
                100,
                25.0F,
                110.0,
                true);

            graph.AddEdge(edge);

            TestGraph serializedGraph = VerifySerialization(graph, serializeGraph);

            TestEdge serializedEdge = serializedGraph.Edges.First();

            if (keepIds)
            {
                Assert.AreEqual(edge.ID, serializedEdge.ID);
            }
            Assert.AreEqual(edge.String, serializedEdge.String);
            Assert.AreEqual(edge.Int, serializedEdge.Int);
            Assert.AreEqual(edge.Long, serializedEdge.Long);
            Assert.AreEqual(edge.Float, serializedEdge.Float);
            Assert.AreEqual(edge.Double, serializedEdge.Double);
            Assert.AreEqual(edge.Bool, serializedEdge.Bool);
        }
示例#2
0
        public void GraphMLSerializationWithValidation_WriteVertex(
            [NotNull, InstantHandle] Func <TestGraph, string> serializeGraph,
            bool _)
        {
            var graph = new TestGraph
            {
                Bool        = true,
                Double      = 1.0,
                Float       = 2.0F,
                Int         = 10,
                Long        = 100,
                String      = "foo",
                BoolArray   = Bools,
                IntArray    = Ints,
                LongArray   = Longs,
                FloatArray  = Floats,
                DoubleArray = Doubles,
                StringArray = Strings,
                NullArray   = null,
                BoolIList   = BoolsList,
                IntIList    = IntsList,
                LongIList   = LongsList,
                FloatIList  = FloatsList,
                DoubleIList = DoublesList,
                StringIList = StringsList
            };

            var vertex = new TestVertex("v1")
            {
                StringDefault = "bar",
                String        = "string",
                Int           = 10,
                Long          = 20,
                Float         = 25.0F,
                Double        = 30.0,
                Bool          = true,
                IntArray      = new[] { 1, 2, 3, 4 },
                IntIList      = new[] { 4, 5, 6, 7 }
            };

            graph.AddVertex(vertex);

            TestGraph serializedGraph = VerifySerialization(graph, serializeGraph);

            Assert.AreEqual(graph.Bool, serializedGraph.Bool);
            Assert.AreEqual(graph.Double, serializedGraph.Double);
            Assert.AreEqual(graph.Float, serializedGraph.Float);
            Assert.AreEqual(graph.Int, serializedGraph.Int);
            Assert.AreEqual(graph.Long, serializedGraph.Long);
            Assert.AreEqual(graph.String, serializedGraph.String);
            CollectionAssert.AreEqual(graph.BoolArray, serializedGraph.BoolArray);
            CollectionAssert.AreEqual(graph.IntArray, serializedGraph.IntArray);
            CollectionAssert.AreEqual(graph.LongArray, serializedGraph.LongArray);
            CollectionAssert.AreEqual(graph.StringArray, serializedGraph.StringArray);
            CollectionAssert.AreEqual(graph.FloatArray, serializedGraph.FloatArray, new FloatComparer(0.001F));
            CollectionAssert.AreEqual(graph.DoubleArray, serializedGraph.DoubleArray, new DoubleComparer(0.0001));
            CollectionAssert.AreEqual(graph.BoolIList, serializedGraph.BoolIList);
            CollectionAssert.AreEqual(graph.IntIList, serializedGraph.IntIList);
            CollectionAssert.AreEqual(graph.LongIList, serializedGraph.LongIList);
            CollectionAssert.AreEqual(graph.StringIList, serializedGraph.StringIList);
            CollectionAssert.AreEqual(graph.FloatIList, serializedGraph.FloatIList, new FloatComparer(0.001F));
            CollectionAssert.AreEqual(graph.DoubleIList, serializedGraph.DoubleIList, new DoubleComparer(0.0001));

            TestVertex serializedVertex = serializedGraph.Vertices.First();

            Assert.AreEqual("bar", serializedVertex.StringDefault);
            Assert.AreEqual(vertex.String, serializedVertex.String);
            Assert.AreEqual(vertex.Int, serializedVertex.Int);
            Assert.AreEqual(vertex.Long, serializedVertex.Long);
            Assert.AreEqual(vertex.Float, serializedVertex.Float);
            Assert.AreEqual(vertex.Double, serializedVertex.Double);
            Assert.AreEqual(vertex.Bool, serializedVertex.Bool);
            CollectionAssert.AreEqual(vertex.IntArray, serializedVertex.IntArray);
            CollectionAssert.AreEqual(vertex.IntIList, serializedVertex.IntIList);
        }