示例#1
0
        public void TestStringSerializeResourceEmpty()
        {
            Resource empty    = new Resource("http://test.com/ex");
            var      res      = SparqlSerializer.SerializeResource(empty);
            var      expected = "";

            Assert.AreEqual(expected, res);
        }
示例#2
0
        public void TestStringSerializeResource()
        {
            Resource r = new Resource("http://example.com/ex");

            r.AddProperty(Ontologies.dc.title, "MyResource");

            string res      = SparqlSerializer.SerializeResource(r);
            string expected = "<http://example.com/ex> <http://purl.org/dc/elements/1.1/title> 'MyResource'. ";

            Assert.AreEqual(expected, res);
        }
示例#3
0
        public void TestStringSerializeResourceWithMapping()
        {
            PersonContact contact = new PersonContact(new Uri("http://example.com/ex"));

            contact.NameGiven = "Peter";
            var res      = SparqlSerializer.SerializeResource(contact);
            var expected = "<http://example.com/ex> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nameGiven> 'Peter'; <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact>. ";

            Assert.AreEqual(expected, res);

            contact.Language = "DE";
            res = SparqlSerializer.SerializeResource(contact);
            Assert.AreEqual(expected, res);
        }
示例#4
0
        public void TestStringSerializeResource()
        {
            Resource r = new Resource("http://example.com/ex");

            r.AddProperty(Ontologies.dc.title, "MyResource");

            string res      = SparqlSerializer.SerializeResource(r);
            string expected = "<http://example.com/ex> <http://purl.org/dc/elements/1.1/title> 'MyResource'. ";

            Assert.AreEqual(expected, res);


            PersonContact contact = new PersonContact(new Uri("http://example.com/ex"));

            contact.NameGiven = "Peter";
            res      = SparqlSerializer.SerializeResource(contact);
            expected = "<http://example.com/ex> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#nameGiven> 'Peter'; <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact>. ";
            Assert.AreEqual(expected, res);

            contact.Language = "DE";
            res = SparqlSerializer.SerializeResource(contact);
            Assert.AreEqual(expected, res);
        }