예제 #1
0
 protected override void ScenarioSetup()
 {
     Visitor = new Mock <IMappingProviderVisitor>(MockBehavior.Strict);
     Visitor.Setup(instance => instance.Visit(It.IsAny <ICollectionMappingProvider>()));
     Provider = AttributeCollectionMappingProvider.FromAttribute(EntityType, Property, new CollectionAttribute()
     {
         Iri = "test"
     });
 }
        private void BuildPropertyMappings(Type type)
        {
            var propertyAttributes = from property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
                                     from attribute in property.GetCustomAttributes()
                                     select new { Property = property, Attribute = attribute };

            foreach (var definition in propertyAttributes)
            {
                //// TODO: Add support for dictionaries.
                var collectionAttribute = definition.Attribute as CollectionAttribute;
                if (collectionAttribute != null)
                {
                    _entityMappingProviders.Add(AttributeCollectionMappingProvider.FromAttribute(type, definition.Property, collectionAttribute));
                    continue;
                }

                var propertyAttribute = definition.Attribute as PropertyAttribute;
                if (propertyAttribute != null)
                {
                    _entityMappingProviders.Add(AttributePropertyMappingProvider.FromAttribute(type, definition.Property, propertyAttribute));
                }
            }
        }
예제 #3
0
 public void Should_create_an_instance_from_iri_attribute()
 {
     AttributeCollectionMappingProvider.FromAttribute(EntityType, Property, AttributeMadeFrom <TestConverter>("test"))
     .Should().BeOfType <AttributeCollectionMappingProvider>().Which.MatchesMapped <TestConverter>(Property, new Iri("test"));
 }
예제 #4
0
 public void Should_create_an_instance_from_qiri_attribute_with_graph_qiri()
 {
     AttributeCollectionMappingProvider.FromAttribute(EntityType, Property, AttributeMadeFrom <TestConverter>("term", "test", "graph", "test"))
     .Should().BeOfType <AttributeCollectionMappingProvider>()
     .Which.MatchesMapped <TestConverter>(Property, new QIriMapping("test", new Iri("test_")), new Iri("test_term"), new Iri("test_graph"));
 }
예제 #5
0
 internal static void MatchesMapped <TConverter>(this AttributeCollectionMappingProvider provider, PropertyInfo property, Iri term, Iri graph = null, CollectionStorageModel storageModel = CollectionStorageModel.Simple)
 {
     provider.MatchesMapped(property, typeof(TConverter), null, term, graph).StoreAs.Should().Be(storageModel);
 }