public void GraphDiffEqualGraphs2()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            g.LoadFromFile("resources\\InferenceTest.ttl");
            h.LoadFromFile("resources\\InferenceTest.ttl");

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.True(report.AreEqual, "Graphs should be equal");
        }
示例#2
0
        public void GraphDiffEqualGraphs2()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            FileLoader.Load(g, "InferenceTest.ttl");
            FileLoader.Load(h, "InferenceTest.ttl");

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.IsTrue(report.AreEqual, "Graphs should be equal");
        }
        public void GraphDiffDifferentGraphs()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            g.LoadFromFile("resources\\InferenceTest.ttl");
            h.LoadFromFile("resources\\Turtle.ttl");

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.False(report.AreEqual, "Graphs should not be equal");
        }
        public void GraphDiffNullReferenceB()
        {
            Graph g = new Graph();

            g.LoadFromFile("resources\\InferenceTest.ttl");

            GraphDiffReport report = g.Difference(null);

            TestTools.ShowDifferences(report);

            Assert.False(report.AreEqual, "Graphs should have been reported as non-equal for one null reference");
            Assert.True(report.AreDifferentSizes, "Graphs should have been reported as different sizes for one null reference");
            Assert.True(report.RemovedTriples.Any(), "Report should list removed triples");
        }
示例#5
0
        public void GraphDiffDifferentGraphs()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            FileLoader.Load(g, "InferenceTest.ttl");
            FileLoader.Load(h, "Turtle.ttl");

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.IsFalse(report.AreEqual, "Graphs should not be equal");
        }
示例#6
0
        public void GraphMatchTrivial1()
        {
            Graph g = new Graph();

            g.LoadFromFile("resources/turtle11-unofficial/test-13.ttl");
            Graph h = new Graph();

            h.LoadFromFile("resources/turtle11-unofficial/test-13.out", new NTriplesParser());

            GraphDiffReport report = g.Difference(h);

            if (!report.AreEqual)
            {
                TestTools.ShowDifferences(report);
            }
            Assert.IsTrue(report.AreEqual);
        }
        private static void TestGraphDiff(string testGraphName)
        {
            Graph a = new Graph();

            a.LoadFromFile(string.Format("resources\\diff_cases\\{0}_a.ttl", testGraphName));
            Graph b = new Graph();

            b.LoadFromFile(string.Format("resources\\diff_cases\\{0}_b.ttl", testGraphName));

            var diff = a.Difference(b);

            if (!diff.AreEqual)
            {
                TestTools.ShowDifferences(diff);
            }
            Assert.True(diff.AreEqual);
        }
        public void GraphDiffRemovedGroundTriples()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            g.LoadFromFile("resources\\InferenceTest.ttl");
            h.LoadFromFile("resources\\InferenceTest.ttl");

            //Remove Triples about Ford Fiestas from 2nd Graph
            h.Retract(h.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")).ToList());

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.False(report.AreEqual, "Graphs should not have been reported as equal");
            Assert.True(report.RemovedTriples.Any(), "Difference should have reported some Removed Triples");
        }
        public void GraphDiffRemovedMSG()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            g.LoadFromFile("resources\\InferenceTest.ttl");
            h.LoadFromFile("resources\\InferenceTest.ttl");

            //Remove MSG from 2nd Graph
            INode toRemove = h.Nodes.BlankNodes().FirstOrDefault();

            Skip.If(toRemove == null, "No MSGs in test graph");
            h.Retract(h.GetTriplesWithSubject(toRemove).ToList());

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.False(report.AreEqual, "Graphs should not have been reported as equal");
            Assert.True(report.RemovedMSGs.Any(), "Difference should have reported some Removed MSGs");
        }
        public void GraphDiffAddedMSG()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            g.LoadFromFile("resources\\InferenceTest.ttl");
            h.LoadFromFile("resources\\InferenceTest.ttl");

            //Add additional Triple to 2nd Graph
            INode    blank    = h.CreateBlankNode();
            IUriNode subClass = h.CreateUriNode("rdfs:subClassOf");
            IUriNode vehicle  = h.CreateUriNode("eg:Vehicle");

            h.Assert(new Triple(blank, subClass, vehicle));

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.False(report.AreEqual, "Graphs should not have been reported as equal");
            Assert.True(report.AddedMSGs.Any(), "Difference should have reported some Added MSGs");
        }
示例#11
0
        public void GraphDiffAddedGroundTriples()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            FileLoader.Load(g, "InferenceTest.ttl");
            FileLoader.Load(h, "InferenceTest.ttl");

            //Add additional Triple to 2nd Graph
            IUriNode spaceVehicle = h.CreateUriNode("eg:SpaceVehicle");
            IUriNode subClass     = h.CreateUriNode("rdfs:subClassOf");
            IUriNode vehicle      = h.CreateUriNode("eg:Vehicle");

            h.Assert(new Triple(spaceVehicle, subClass, vehicle));

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.IsFalse(report.AreEqual, "Graphs should not have been reported as equal");
            Assert.IsTrue(report.AddedTriples.Any(), "Difference should have reported some Added Triples");
        }
示例#12
0
        public void GraphMatchTrivial2()
        {
            Graph      g    = new Graph();
            IBlankNode a    = g.CreateBlankNode("b1");
            IBlankNode b    = g.CreateBlankNode("b2");
            IBlankNode c    = g.CreateBlankNode("b3");
            INode      pred = g.CreateUriNode(UriFactory.Create("http://predicate"));

            g.Assert(a, pred, g.CreateLiteralNode("A"));
            g.Assert(a, pred, b);
            g.Assert(b, pred, g.CreateLiteralNode("B"));
            g.Assert(b, pred, c);
            g.Assert(c, pred, g.CreateLiteralNode("C"));
            g.Assert(c, pred, a);

            Graph      h     = new Graph();
            IBlankNode a2    = h.CreateBlankNode("b4");
            IBlankNode b2    = h.CreateBlankNode("b5");
            IBlankNode c2    = h.CreateBlankNode("b3");
            INode      pred2 = h.CreateUriNode(UriFactory.Create("http://predicate"));

            h.Assert(a2, pred2, h.CreateLiteralNode("A"));
            h.Assert(a2, pred2, b2);
            h.Assert(b2, pred2, h.CreateLiteralNode("B"));
            h.Assert(b2, pred2, c2);
            h.Assert(c2, pred2, h.CreateLiteralNode("C"));
            h.Assert(c2, pred2, a2);

            GraphDiffReport report = g.Difference(h);

            if (!report.AreEqual)
            {
                TestTools.ShowDifferences(report);
            }
            Assert.IsTrue(report.AreEqual);
        }
示例#13
0
        public void GraphDiffRemovedMSG()
        {
            Graph g = new Graph();
            Graph h = new Graph();

            FileLoader.Load(g, "InferenceTest.ttl");
            FileLoader.Load(h, "InferenceTest.ttl");

            //Remove MSG from 2nd Graph
            INode toRemove = h.Nodes.BlankNodes().FirstOrDefault();

            if (toRemove == null)
            {
                Assert.Inconclusive("No MSGs in test graph");
            }
            h.Retract(h.GetTriplesWithSubject(toRemove).ToList());

            GraphDiffReport report = g.Difference(h);

            TestTools.ShowDifferences(report);

            Assert.IsFalse(report.AreEqual, "Graphs should not have been reported as equal");
            Assert.IsTrue(report.RemovedMSGs.Any(), "Difference should have reported some Removed MSGs");
        }