Exemplo n.º 1
0
        private static void AssertClassMap <T>(T example, string container, string ocategory, IEnumerable <string> oclass) where T : class
        {
            var mapping = new AutoClassMap <T>()
                          .PerformMapping(container, ocategory, false, oclass, false)
                          .CastTo <AutoClassMap <T> >();
            var mappedProperties = mapping.PropertyMappings;

            mappedProperties.Should().Have.Count.EqualTo(8);
            mappedProperties[0].IsDistinguishedName.Should().Be.True();
            mappedProperties[1].ReadOnlyConfiguration.Should().Be.EqualTo(ReadOnly.Always);
            mapping.FieldValueEx <string>("_namingContext").Should().Be.EqualTo(container);
            mapping.PropertyValue <bool>("IncludeObjectCategory").Should().Be.False();
            mapping.FieldValueEx <string>("_objectCategory").Should().Be.EqualTo("oc");
            mapping.FieldValueEx <IEnumerable <string> >("_objectClass").Should().Be.Equals(new[] { "cl" });
            mapping.PropertyValue <bool>("IncludeObjectClasses").Should().Be.False();
        }
Exemplo n.º 2
0
        public void AutoClassMap_StandardType_MapsOnlyPropertiesWithGettersAndSetters()
        {
            var mapping = new AutoClassMap <AutoClassMapTest>().PerformMapping("container", "oc", false, new List <string> {
                "cl"
            }, false)
                          .CastTo <AutoClassMap <AutoClassMapTest> >();
            var propertyMappings = mapping.PropertyMappings;

            propertyMappings[0].IsDistinguishedName.Should().Be.True();
            propertyMappings[1].ReadOnlyConfiguration.Should().Be.EqualTo(ReadOnly.Always);
            propertyMappings.Should().Have.Count.EqualTo(4);
            propertyMappings.Count(p => p.PropertyInfo.Name == "Property1" || p.PropertyInfo.Name == "Property3" || p.PropertyInfo.Name == "DistinguishedName" || p.PropertyInfo.Name == "Cn")
            .Should().Be.EqualTo(2);
            mapping.FieldValueEx <string>("_namingContext").Should().Be.EqualTo("container");
            mapping.FieldValueEx <string>("_objectCategory").Should().Be.EqualTo("oc");
            mapping.PropertyValue <bool>("IncludeObjectCategory").Should().Be.False();
            mapping.FieldValueEx <IEnumerable <string> >("_objectClass").Should().Be.Equals(new[] { "cl" });
            mapping.PropertyValue <bool>("IncludeObjectClasses").Should().Be.False();
        }