public void Should_be_for_closed_entity_type()
        {
            // given
            var provider = new ClosedGenericEntityMappingProvider(CreateOpenGenericProvider("MappedProperty1"), typeof(int));

            // when
            var entityType = provider.EntityType;

            // then
            entityType.Should().Be<IGenericParent<int>>();
        }
        public void Should_return_mappings_for_closed_properties(string propertyName, Type expectedType)
        {
            // given
            var provider = new ClosedGenericEntityMappingProvider(CreateOpenGenericProvider(propertyName), typeof(int));

            // when
            var propertyMapping = provider.Properties.Single();

            // then
            propertyMapping.Should().NotBeNull();
            propertyMapping.PropertyInfo.PropertyType.Should().Be(expectedType);
        }
        private ICollection<IPropertyMappingProvider> CombineProperties()
        {
            var providers = new Dictionary<string, IPropertyMappingProvider>();
            foreach (var property in _mainProvider.Properties)
            {
                providers[property.PropertyInfo.Name] = property;
            }

            var parents = new Queue<Type>(_mainProvider.EntityType.GetImmediateParents());
            while (parents.Any())
            {
                var iface = parents.Dequeue();
                foreach (var immediateParent in iface.GetImmediateParents())
                {
                    parents.Enqueue(immediateParent);
                    if (immediateParent.IsGenericTypeDefinition && _parentProviders.ContainsKey(immediateParent))
                    {
                        var parentMapping = _parentProviders[immediateParent];
                        _parentProviders[iface] = new ClosedGenericEntityMappingProvider(
                            parentMapping, iface.GetGenericArguments());
                    }
                }

                if (_parentProviders.ContainsKey(iface))
                {
                    var provider = _parentProviders[iface];
                    foreach (var property in provider.Properties)
                    {
                        if (!providers.ContainsKey(property.PropertyInfo.Name))
                        {
                            providers[property.PropertyInfo.Name] = property;
                        }
                    }
                }
            }

            return providers.Values;
        }