public void NodeCompareToMixedNodes2()
        {
            Graph         g = new Graph();
            IBlankNode    b = g.CreateBlankNode();
            ILiteralNode  l = g.CreateLiteralNode("literal", "en");
            IUriNode      u = g.CreateUriNode(new Uri("http://example.org"));
            IVariableNode v = g.CreateVariableNode("var");

            int c = b.CompareTo(l);

            Assert.Equal(c * -1, l.CompareTo(b));
            c = b.CompareTo(u);
            Assert.Equal(c * -1, u.CompareTo(b));
            c = b.CompareTo(v);
            Assert.Equal(c * -1, v.CompareTo(b));

            c = l.CompareTo(b);
            Assert.Equal(c * -1, b.CompareTo(l));
            c = l.CompareTo(u);
            Assert.Equal(c * -1, u.CompareTo(l));
            c = l.CompareTo(v);
            Assert.Equal(c * -1, v.CompareTo(l));

            c = u.CompareTo(b);
            Assert.Equal(c * -1, b.CompareTo(u));
            c = u.CompareTo(l);
            Assert.Equal(c * -1, l.CompareTo(u));
            c = u.CompareTo(v);
            Assert.Equal(c * -1, v.CompareTo(u));

            c = v.CompareTo(b);
            Assert.Equal(c * -1, b.CompareTo(v));
            c = v.CompareTo(l);
            Assert.Equal(c * -1, l.CompareTo(v));
            c = v.CompareTo(u);
            Assert.Equal(c * -1, u.CompareTo(v));
        }
Exemple #2
0
        public void NodeCompareToMixedNodes2()
        {
            Graph         g = new Graph();
            IBlankNode    b = g.CreateBlankNode();
            ILiteralNode  l = g.CreateLiteralNode("literal", "en");
            IUriNode      u = g.CreateUriNode(new Uri("http://example.org"));
            IVariableNode v = g.CreateVariableNode("var");

            int c = b.CompareTo(l);

            Assert.AreEqual(c * -1, l.CompareTo(b), "Expected l compareTo b to be inverse of b compareTo l");
            c = b.CompareTo(u);
            Assert.AreEqual(c * -1, u.CompareTo(b), "Expected l compareTo u to be inverse of u compareTo l");
            c = b.CompareTo(v);
            Assert.AreEqual(c * -1, v.CompareTo(b), "Expected l compareTo v to be inverse of v compareTo l");

            c = l.CompareTo(b);
            Assert.AreEqual(c * -1, b.CompareTo(l), "Expected b compareTo l to be inverse of l compareTo b");
            c = l.CompareTo(u);
            Assert.AreEqual(c * -1, u.CompareTo(l), "Expected u compareTo l to be inverse of l compareTo u");
            c = l.CompareTo(v);
            Assert.AreEqual(c * -1, v.CompareTo(l), "Expected v compareTo l to be inverse of l compareTo v");

            c = u.CompareTo(b);
            Assert.AreEqual(c * -1, b.CompareTo(u), "Expected b compareTo u to be inverse of u compareTo b");
            c = u.CompareTo(l);
            Assert.AreEqual(c * -1, l.CompareTo(u), "Expected l compareTo u to be inverse of u compareTo l");
            c = u.CompareTo(v);
            Assert.AreEqual(c * -1, v.CompareTo(u), "Expected v compareTo u to be inverse of u compareTo v");

            c = v.CompareTo(b);
            Assert.AreEqual(c * -1, b.CompareTo(v), "Expected b compareTo v to be inverse of v compareTo b");
            c = v.CompareTo(l);
            Assert.AreEqual(c * -1, l.CompareTo(v), "Expected l compareTo v to be inverse of v compareTo l");
            c = v.CompareTo(u);
            Assert.AreEqual(c * -1, u.CompareTo(v), "Expected u compareTo v to be inverse of v compareTo u");
        }