public void Getting_unknown_predicate_should_use_the_property_name()
        {
            // given
            _store.Setup(g => g.GetObjectsForPredicate(_entity.Id, It.IsAny<Uri>(), It.IsAny<Uri>())).Returns(new Node[0]);
            dynamic accessor = new OntologyAccessor(_entity, _ontology, new TestTransformerCatalog());

            // when
            var givenName = accessor.fullName;

            // then
            _store.Verify(s => s.GetObjectsForPredicate(_entity.Id, new Property("fullName").InOntology(_ontology).Uri, null), Times.Once);
        }
        public void Getting_unknown_predicate_should_use_the_property_name()
        {
            // given
            _store.Setup(g => g.GetObjectsForPredicate(_entity.Id, It.IsAny <Uri>(), It.IsAny <Uri>())).Returns(new Node[0]);
            dynamic accessor = new OntologyAccessor(_entity, _ontology, new FallbackNodeConverter(new ConverterCatalog()), new TestTransformerCatalog());

            // when
            var givenName = accessor.fullName;

            // then
            _store.Verify(s => s.GetObjectsForPredicate(_entity.Id, new Property("fullName").InOntology(_ontology).Uri, null), Times.Once);
        }
Example #3
0
        private bool TryGetOntologyAccessor(string prefix, out OntologyAccessor result)
        {
            if (_ontologyAccessors.ContainsKey(prefix))
            {
                result = _ontologyAccessors[prefix];
                return(true);
            }

            var ontology = _context.Ontologies.Ontologies.FirstOrDefault(o => o.Prefix == prefix);

            if (ontology != null)
            {
                _ontologyAccessors[prefix] = new OntologyAccessor(this, ontology, _fallbackNodeConverter, _transformerCatalog);
                result = _ontologyAccessors[prefix];
                return(true);
            }

            result = null;
            return(false);
        }