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)); } } }
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")); }
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")); }