Exemplo n.º 1
0
        public override IGenericGraph AssembleEntityStatements(IInputSource input, IStatementsConfig entityMap, IDictionary <string, string> nsMap)
        {
            cancelled    = false;
            subjectGraph = new VDSGraph();
            subjectGraph.NamespaceMap.Import(NamespaceHelper.ToIGraphNamespaceMap(nsMap));
            foreach (IDictionary <string, string> row in input.GetEntityRecords(entityMap.GetSourceName()))
            {
                if (cancelled)
                {
                    break;
                }

                Uri subjectURI = URIFactory.FromTemplate(entityMap.GetTemplate(), row);
                if (subjectURI == null)
                {
                    break;
                }

                IUriNode subject = subjectGraph.CreateUriNode(subjectURI);
                subjectGraph.Assert(subject, subjectGraph.CreateUriNode("rdf:type"), subjectGraph.CreateUriNode(entityMap.GetClassName()));

                AssemblePredicateObjectsStatements(subject, row, entityMap.GetRelationObjectConfigs());
            }
            return(subjectGraph);
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            //Mock creation
            _mockInputSource  = Mock.Of <IInputSource>();
            _mockMapperConfig = Mock.Of <IMapperConfig>();
            IStatementsConfig   statementsConfig = Mock.Of <IStatementsConfig>();
            IStatementAssembler assemblerMock    = Mock.Of <IStatementAssembler>();

            //Mock setups
            Mock.Get(_mockMapperConfig)
            .Setup(f => f.ListNamespaces())
            .Returns(new Dictionary <string, string>()
            {
                { "prefix1", "ns1" },
                { "prefix2", "ns2" }
            });

            Mock.Get(_mockMapperConfig)
            .Setup(f => f.ListStatementsConfigs())
            .Returns(new List <IStatementsConfig>()
            {
                statementsConfig
            });

            //Instance creation
            BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance;

            _graphMapper = (T)Activator.CreateInstance(typeof(T), flags, null, new object[] { assemblerMock }, null);

            //Fake setup
            IGenericGraph fakeGraph = (IGenericGraph)Activator.CreateInstance(_graphMapper.GetGraphType());

            //Mock setup
            Mock.Get(assemblerMock)
            .Setup(f => f.AssembleEntityStatements(
                       It.IsAny <IInputSource>(),
                       It.IsAny <IStatementsConfig>(),
                       It.IsAny <IDictionary <string, string> >()))
            .Returns(fakeGraph);
        }
        public void SetUp()
        {
            _statementAssembler   = new T();
            _mockInputSource      = Mock.Of <IInputSource>();
            _mockStatementsConfig = Mock.Of <IStatementsConfig>();

            Mock.Get(_mockInputSource).Setup(f => f.GetEntityRecords(It.IsAny <string>()))
            .Returns(
                new List <IDictionary <string, string> >()
            {
                { new Dictionary <string, string>()
                  {
                      { "EMPNO", "7369" },
                      { "ENAME", "SMITH" },
                      { "JOB", "CLERK" },
                      { "DEPTNO", "10" },
                  } }
            }
                );

            _fakeNamespaceMap = new Dictionary <string, string>()
            {
                { "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" },
                { "ex", "http://www.example.org/ns#" }
            };

            IRelationConfig relationConfigMock = Mock.Of <IRelationConfig>();

            Mock.Get(relationConfigMock).Setup(f => f.GetRelationName()).Returns("ex:name");
            IObjectsConfig objectsConfigMock = Mock.Of <IObjectsConfig>();

            Mock.Get(objectsConfigMock).Setup(f => f.GetSourceName()).Returns("ENAME");
            Mock.Get(_mockStatementsConfig).Setup(f => f.GetClassName()).Returns("ex:Employee");
            Mock.Get(_mockStatementsConfig).Setup(f => f.GetRelationObjectConfigs()).Returns(new Dictionary <IRelationConfig, IObjectsConfig>()
            {
                { relationConfigMock, objectsConfigMock }
            });
            Mock.Get(_mockStatementsConfig).Setup(f => f.GetTemplate()).Returns("http://www.example.org/employee/{EMPNO}");
        }
 public abstract IGenericGraph AssembleEntityStatements(IInputSource source, IStatementsConfig entityConfig, IDictionary <string, string> nsMap);
 public void SetUp()
 {
     _statementsConfig = new T();
 }
Exemplo n.º 6
0
 public void AddStatementsConfig(IStatementsConfig config)
 {
     _statementsConfigs.Add(config);
 }