Beispiel #1
0
        public void SetUp()
        {
            _rdfLoader    = Mock.Of <IRdfLoader>();
            _turtleParser = Mock.Of <TurtleParser>();
            _r2rmlParser  = new R2RMLParser(_rdfLoader, _turtleParser);

            Mock.Get(_rdfLoader).Setup(f => f.LoadFromFile(It.IsAny <Graph>(), It.Is <string>(s => !s.Equals(_dirPath + _emptyFile)), _turtleParser)).Throws <FileNotFoundException>();
            Mock.Get(_rdfLoader).Setup(f => f.LoadFromFile(It.IsAny <Graph>(), _dirPath + _prefixOnlyFIle, _turtleParser))
            .Callback <IGraph, string, IRdfReader>((graph, filename, rdfReader) =>
            {
                graph.NamespaceMap.AddNamespace("rr", UriFactory.Create("http://www.w3.org/ns/r2rml#"));
                graph.NamespaceMap.AddNamespace(_examplePrefix, _examplePrefixUri);
            });
            Mock.Get(_rdfLoader).Setup(f => f.LoadFromFile(It.IsAny <Graph>(), _dirPath + _validFile, _turtleParser))
            .Callback <IGraph, string, IRdfReader>((graph, filename, rdfReader) =>
            {
                if (graph.IsEmpty && graph.BaseUri == null)
                {
                    graph.BaseUri = UriFactory.Create("file:///" + filename);
                }
                IUriNode triplesMap = graph.CreateUriNode(UriFactory.Create(graph.BaseUri.ToString() + "#TriplesMap1"));

                graph.NamespaceMap.AddNamespace("rr", UriFactory.Create("http://www.w3.org/ns/r2rml#"));
                graph.NamespaceMap.AddNamespace(_examplePrefix, _examplePrefixUri);
                graph.Assert(triplesMap, graph.CreateUriNode("rr:logicalTable"), graph.CreateBlankNode("ltNode"));
                graph.Assert(graph.GetBlankNode("ltNode"), graph.CreateUriNode("rr:tableName"), graph.CreateLiteralNode("EMP"));
                graph.Assert(triplesMap, graph.CreateUriNode("rr:subjectMap"), graph.CreateBlankNode("smNode"));
                graph.Assert(graph.GetBlankNode("smNode"), graph.CreateUriNode("rr:template"), graph.CreateLiteralNode("http://www.example.com/employee/{EMPNO}"));
                graph.Assert(graph.GetBlankNode("smNode"), graph.CreateUriNode("rr:class"), graph.CreateUriNode("ex:Employee"));
                graph.Assert(triplesMap, graph.CreateUriNode("rr:predicateObjectMap"), graph.CreateBlankNode("pomNode"));
                graph.Assert(graph.GetBlankNode("pomNode"), graph.CreateUriNode("rr:predicate"), graph.CreateUriNode("ex:name"));
                graph.Assert(graph.GetBlankNode("pomNode"), graph.CreateUriNode("rr:objectMap"), graph.CreateBlankNode("omNode"));
                graph.Assert(graph.GetBlankNode("omNode"), graph.CreateUriNode("rr:column"), graph.CreateLiteralNode("ENAME"));
            });
        }
 public R2RMLParser(IRdfLoader loader, TurtleParser parser)
 {
     _rdfLoader    = loader;
     _turtleParser = parser;
 }
 public R2RMLParser()
 {
     _rdfLoader    = new RdfLoaderWrapper();
     _turtleParser = new TurtleParser();
 }