예제 #1
0
        public virtual void TestStatementsWithAnonymousVariable()
        {
            TurtleWriter instance = CreateInstance();

            instance.Add(new Statement(new Variable("var"), "b", (Entity)"C"));
            instance.Close();

            string expected = "?var <b> <C>.";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #2
0
        public virtual void TestWriteStatementWithLiteralOfTypeBoolean()
        {
            TurtleWriter instance = CreateInstance();

            instance.Add(new Statement("A", "b", Literal.FromValue(true)));
            instance.Close();

            string expected = "<A> <b> true.";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #3
0
        public virtual void TestWriteStatementWithLiteralHavingDataType()
        {
            TurtleWriter instance = CreateInstance();

            instance.Add(new Statement("A", "b", Literal.FromValue("C")));
            instance.Close();

            string expected = "<A> <b> \"C\"^^<http://www.w3.org/2001/XMLSchema#string>.";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #4
0
        public virtual void TestWriteStatementWithLiteralHavingLanguage()
        {
            TurtleWriter instance = CreateInstance();

            instance.Add(new Statement("A", "b", new Literal("C", "en", "http://www.w3.org/2001/XMLSchema#string")));
            instance.Close();

            string expected = "<A> <b> \"C\"@en.";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #5
0
        public virtual void TestStatementWithAnonymousBNode()
        {
            BNode        bNode    = new BNode();
            TurtleWriter instance = CreateInstance();

            instance.Add(new Statement(bNode, "b", (Entity)"C"));
            instance.Close();

            string expected = bNode + " <b> <C>.";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #6
0
        public virtual void TestWriteWithNamespaces()
        {
            TurtleWriter instance = CreateInstance();

            instance.Namespaces.AddNamespace("http://example.org/", "ex");
            instance.Add(new Statement("http://example.org/A", Predicate.RdfType, (Entity)"X"));
            instance.Close();

            string expected = "@prefix ex: <http://example.org/>.\nex:A a <X>.";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #7
0
        public virtual void TestWriteStatementWithLiteralHavingDataTypeUsingNamespace()
        {
            TurtleWriter instance = CreateInstance();

            instance.Namespaces.AddNamespace("http://www.w3.org/2001/XMLSchema#", "xsd");
            instance.Add(new Statement("A", "b", Literal.FromValue("C")));
            instance.Close();

            string expected = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.\n<A> <b> \"C\"^^xsd:string.";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #8
0
        public virtual void TestSimpleStatements()
        {
            TurtleWriter instance = CreateInstance();

            instance.Add(new Statement("S", Predicate.RdfType, (Entity)"X"));
            instance.Add(new Statement("S", Predicate.RdfType, (Entity)"Y"));
            instance.Add(new Statement("S", "o", (Entity)"Z"));
            instance.Add(new Statement("P", "o", (Literal)"s"));
            instance.Close();

            string expected = "<S> a <X>,\n" +
                              "\t\t<Y>;\n" +
                              "\t<o> <Z>.\n" +
                              "<P> <o> \"s\".";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #9
0
        public virtual void TestWriteEscapesAllResources()
        {
            // note: should test for unicode characters >= \U0001000,
            //       but Mono on Linux does not support this. (works in Windows .Net)
            string subject = "http://\u00E9xampl\u00E8.org/\t\n\u000B\u000C\r\u000E\u0012\u001F";

            TurtleWriter instance = CreateInstance();

            instance.Namespaces.AddNamespace("http://\u00E9xampl\u00E8.org/", "ex");
            instance.Add(new Statement(subject, "\uABCD", (Literal)"\u0020\u0021\u000A"));
            instance.Close();

            string expected = @"@prefix ex: <http://\u00E9xampl\u00E8.org/>." + '\n'
                              + @"ex:\t\n\u000B\u000C\r\u000E\u0012\u001F <\uABCD> " + "\" !\\n\".";

            Assert.AreEqual(expected, writer.ToString());
        }
예제 #10
0
        public virtual void TestWriteFormulaWithOneStatement()
        {
            TurtleWriter instance = CreateInstance();

            BNode statementId = new BNode("s");

            instance.Add(new Statement("A", "b", (Entity)"C", statementId));
            instance.Close();

            string expected = "_:s a <http://www.w3.org/2000/10/swap/log#Formula>;\n" +
                              "\t<http://www.w3.org/2000/10/swap/log#includes> _:bnode.\n" +
                              "_:bnode a <http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement>;\n" +
                              "\t<http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <A>;\n" +
                              "\t<http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <b>;\n" +
                              "\t<http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <C>.";

            Assert.AreEqual(expected, Regex.Replace(writer.ToString(), @"_:bnode\d+", "_:bnode"));
        }