public void Should_fail_when_getting_ambiguous_property_mapping()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IChild>();

            // then
            mapping.Invoking(m => m.PropertyFor("Member")).ShouldThrow <AmbiguousPropertyException>();
        }
Exemple #2
0
        public void Type_can_be_mapped_without_rdf_type()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IUntypedAnimal>();

            // then
            Assert.That(mapping.Classes, Is.Empty);
            Assert.That(mapping.PropertyFor("Name"), Is.Not.Null);
        }
        public void Should_respect_hiding_members()
        {
            // given, when
            var mapping = MappingsRepository.MappingFor <IHidesMember>();

            // then
            mapping.PropertyFor("MappedProperty1").Uri.Should().Be(new Uri("urn:hidden:mapping"));
            mapping.PropertyFor("MappedProperty2").Uri.Should().Be(new Uri("urn:hidden:fluent"));
        }
        public void Should_retain_class_inheritance_in_concrete_entities()
        {
            // given
            var mapping = MappingsRepository.MappingFor <ConcreteEntityChild>();

            // when
            var property = mapping.PropertyFor("UnMappedProperty");

            // then
            property.Uri.Should().Be(new Uri("urn:concrete:class"));
        }
        public void Should_read_all_properties_from_fluent_mapped_hierarchy_of_concrete_classes()
        {
            // given
            var mapping = MappingsRepository.MappingFor <FluentNoIEntityInnerMapChild>();

            // when
            var properties = mapping.Properties;

            // then
            properties.Should().HaveCount(2);
        }
        public void Should_contain_closed_generic_mappings_not_mapped_explicitly()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IGenericParent <int> >();

            // when
            var property = mapping.PropertyFor("MappedProperty2");

            // then
            property.ReturnType.Should().Be(typeof(int));
        }
        public void Should_contain_open_generic_mappings()
        {
            // given
            var mapping = MappingsRepository.MappingFor(typeof(IGenericParent <>));

            // when
            var property = mapping.PropertyFor("MappedProperty2");

            // then
            property.ReturnType.Name.Should().Be("T");
        }
        public void Should_use_open_generic_mapping_fallback()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IDerived>();

            // when
            var property = mapping.PropertyFor("MappedProperty2");

            // then
            property.Uri.Should().Be(new Uri("urn:open:mapping2"));
        }
        public void Should_fill_return_types_for_inherited_generic_properties()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IDerived>();

            // when
            var property = mapping.PropertyFor("MappedProperty2");

            // then
            property.ReturnType.Should().Be(typeof(int));
        }
        public void Should_inherit_properties_in_concrete_entity_class()
        {
            // given
            var mapping = MappingsRepository.MappingFor <ConcreteEntity>();

            // when
            var property = mapping.PropertyFor("MappedProperty1");

            // then
            property.Uri.Should().Be(new Uri("urn:open:mapping1"));
        }
        public void Should_give_access_to_all_ambiguous_property_mappings()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IChild>();

            // when
            var properties = mapping.Properties;

            // then
            properties.Should().HaveCount(4);
        }
Exemple #12
0
        public void Explicit_setting_for_collection_converter_should_not_be_replaced_by_convention()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IEntityWithExplicitConverters>();

            // when
            var property = (ICollectionMapping)mapping.PropertyFor("Collection");

            // then
            property.ElementConverter.Should().BeOfType <BooleanConverter>();
        }
        public void Should_respect_mapping_override(Type type, string expectedUri)
        {
            // given
            var mapping = MappingsRepository.MappingFor(type);

            // when
            var property = mapping.PropertyFor("MappedProperty1");

            // then
            property.Uri.Should().Be(new Uri(expectedUri));
        }
Exemple #14
0
        public void Subclass_should_inehrit_parent_generic_property_mapping()
        {
            // given
            var mapping = MappingsRepository.MappingFor <ISpecificContainer>();

            // when
            var itemsPropertyMapping = (ICollectionMapping)mapping.Properties.First(item => item.Name == "Items");

            // then
            itemsPropertyMapping.StoreAs.Should().Be(StoreAs.SimpleCollection);
        }
Exemple #15
0
        public void Subclass_should_inherit_parent_Class_mappings()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IHuman>();

            // when
            var classMappings = mapping.Classes;

            // then
            classMappings.Should().HaveCount(4);
        }
Exemple #16
0
        public void Mapping_should_allow_dictionary_with_default_key_value()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IEntityWithDictionary>();

            // then
            var propertyMapping = mapping.PropertyFor("SettingsDefault");

            propertyMapping.Should().BeAssignableTo <IDictionaryMapping>();
            propertyMapping.As <IDictionaryMapping>().KeyPredicate.Should().Be(Vocabularies.Rdf.predicate);
            propertyMapping.As <IDictionaryMapping>().ValuePredicate.Should().Be(Vocabularies.Rdf.@object);
        }
Exemple #17
0
        public void Explicit_setting_for_dictionary_value_converter_should_not_be_replaced_by_convention()
        {
            // given
            var generatedEntityType = GetDynamicType("RomanticWeb.TestEntities.IEntityWithExplicitConverters_Dictionary_Entry, RomanticWeb.TestEntities");
            var mapping             = MappingsRepository.MappingFor(generatedEntityType);

            // when
            var property = mapping.PropertyFor("Value");

            // then
            property.Converter.Should().BeOfType <BooleanConverter>();
        }
Exemple #18
0
        public void Mapped_type_should_contain_inherited_properties()
        {
            // given
            var mapping = MappingsRepository.MappingFor <ICarnivore>();

            // when
            var propertyMapping = mapping.PropertyFor("Name");

            // then
            Assert.That(propertyMapping.Name, Is.EqualTo("Name"));
            Assert.That(propertyMapping.Uri, Is.EqualTo(new Uri("http://example/livingThings#name")));
        }
Exemple #19
0
        public void Multimapping_should_not_throw_when_getting_derived_properties()
        {
            // given
            IEntityMapping herbivoreMapping = MappingsRepository.MappingFor <IHerbivore>();
            IEntityMapping carnivoreMapping = MappingsRepository.MappingFor <ICarnivore>();

            // when
            var multiMapping = new MultiMapping(herbivoreMapping, carnivoreMapping);

            // then
            Assert.DoesNotThrow(() => multiMapping.PropertyFor("Name"));
        }
        public void Mapping_of_class_derived_from_generic_class_should_contain_parent_collections_mapped_in_open_generic()
        {
            // given
            var mapping = MappingsRepository.MappingFor <IImplementsGenericWithInt>();

            // when
            var propertyMapping = mapping.PropertyFor("Collection");

            // then
            propertyMapping.Name.Should().Be("Collection");
            propertyMapping.Uri.Should().Be(new Uri("urn:generic:collection"));
        }
Exemple #21
0
        public void Explicit_setting_for_collection_should_not_be_replaced_by_conventions(
            string propertyName, StoreAs asExpected)
        {
            // given
            var mapping = MappingsRepository.MappingFor <IEntityWithCollections>();

            // when
            var property = (ICollectionMapping)mapping.PropertyFor(propertyName);

            // then
            property.StoreAs.Should().Be(asExpected);
        }
Exemple #22
0
        public void Mapped_type_should_have_mapped_class()
        {
            // given
            var mapping = MappingsRepository.MappingFor <ICarnivore>();

            // when
            var classMappings = mapping.Classes.ToList();

            // then
            classMappings.Should().HaveCount(2);
            classMappings.Should()
            .Contain(c => c.IsInherited && c.IsMatch(new[] { new Uri("http://example/livingThings#Animal") }));
            classMappings.Should()
            .Contain(c => !c.IsInherited && c.IsMatch(new[] { new Uri("http://example/livingThings#Carnivore") }));
        }