示例#1
0
        public void Constructor_Initializes_Correctly()
        {
            //arrange
            var propertyMappings = new[]
            { _distinguishedName.Object, _storeGenerated.Object, _readOnly.Object, _updateable.Object };

            //act
            var mapping = new TestObjectMapping("context", propertyMappings,
                                                "category", false, new[] { "class" }, false);

            //assert
            mapping.NamingContext.Should().Be.EqualTo("context");
            mapping.ObjectCategory.Should().Be.EqualTo("category");
            mapping.ObjectClasses.Should().Have.SameSequenceAs(new[] { "class" });
            propertyMappings.ToList().ForEach(x => mapping.GetPropertyMappings()
                                              .Should().Contain(x));
            mapping.GetDistinguishedNameMapping().Should().Be.EqualTo(_distinguishedName.Object);
            mapping.GetPropertyMappingsForAdd().Should().Contain(_updateable.Object).And.Contain(_storeGenerated.Object).And.Have.Count.EqualTo(2);
            mapping.GetPropertyMappingsForUpdate().Should().Contain(_updateable.Object).And.Have.Count.EqualTo(1);
            mapping.IncludeObjectCategory.Should().Be.False();
            mapping.IncludeObjectClasses.Should().Be.False();
            mapping.Properties.ForEach(x =>
            {
                var result = (x.Key == _distinguishedName.Object.PropertyName &&
                              x.Value == _distinguishedName.Object.AttributeName) ||
                             (x.Key == _storeGenerated.Object.PropertyName &&
                              x.Value == _storeGenerated.Object.AttributeName) ||
                             (x.Key == _readOnly.Object.PropertyName &&
                              x.Value == _readOnly.Object.AttributeName) ||
                             (x.Key == _updateable.Object.PropertyName &&
                              x.Value == _updateable.Object.AttributeName);

                result.Should().Be.True();
            });
            mapping.Properties.Count.Should().Be.EqualTo(4);
        }