public void CallAppliersOnList()
        {
            var patternAppliers = new EmptyPatternsAppliersHolder();

            var applier = new Mock<IPatternApplier<PropertyPath, ICollectionPropertiesMapper>>();
            applier.Setup(x => x.Match(It.IsAny<PropertyPath>())).Returns(true);
            patternAppliers.CollectionPath.Add(applier.Object);

            var mapper = new Mapper(domainInspectorMock.Object, patternAppliers);
            mapper.CompileMappingFor(new[] { typeof(MyClass) });

            applier.Verify(x => x.Apply(It.Is<PropertyPath>(pp => pp.LocalMember.Name == "List"), It.IsAny<ICollectionPropertiesMapper>()));
        }
        public void CallAppliersOnManyToMany()
        {
            var patternAppliers = new EmptyPatternsAppliersHolder();

            var applier = new Mock<IPatternApplier<PropertyPath, IManyToManyMapper>>();
            applier.Setup(x => x.Match(It.IsAny<PropertyPath>())).Returns(true);
            patternAppliers.ManyToManyPath.Add(applier.Object);

            var mapper = new Mapper(domainInspectorMock.Object, patternAppliers);
            mapper.CompileMappingFor(new[] { typeof(MyClass) });

            applier.Verify(x => x.Apply(It.IsAny<PropertyPath>(), It.IsAny<IManyToManyMapper>()));
        }
        /// <summary>
        /// Union tow instances of <see cref="IPatternsAppliersHolder"/>.
        /// </summary>
        /// <param name="first">The main <see cref="IPatternsAppliersHolder"/> to union.</param>
        /// <param name="second">The second <see cref="IPatternsAppliersHolder"/> to union.</param>
        /// <returns>A new instance of <see cref="IPatternsAppliersHolder"/> with the result of union.</returns>
        /// <remarks>
        /// The rules of this methods are the same of <see cref="UnionWith{TSubject, TApplyTo}"/>.
        /// The result does not contains duplicated appliers.
        /// When an applier with the same type-name exists in both side the instance contained in <paramref name="second"/> will be returned.
        /// </remarks>
        public static IPatternsAppliersHolder UnionWith(this IPatternsAppliersHolder first, IPatternsAppliersHolder second)
        {
            if (first == null)
            {
                throw new ArgumentNullException("first");
            }
            var result = new EmptyPatternsAppliersHolder();

            UnionWithPatternsAppliersHolders(first, result);
            if (second != null)
            {
                UnionWithPatternsAppliersHolders(second, result);
            }
            return(result);
        }
        private static void UnionWithPatternsAppliersHolders(IPatternsAppliersHolder source, EmptyPatternsAppliersHolder destination)
        {
            UnionWithAppliersCollection(source.RootClass, destination.RootClass);
            UnionWithAppliersCollection(source.JoinedSubclass, destination.JoinedSubclass);
            UnionWithAppliersCollection(source.Subclass, destination.Subclass);
            UnionWithAppliersCollection(source.UnionSubclass, destination.UnionSubclass);
            UnionWithAppliersCollection(source.Component, destination.Component);
            UnionWithAppliersCollection(source.ComponentProperty, destination.ComponentProperty);
            UnionWithAppliersCollection(source.ComponentPropertyPath, destination.ComponentPropertyPath);

            UnionWithAppliersCollection(source.Poid, destination.Poid);
            UnionWithAppliersCollection(source.Version, destination.Version);

            UnionWithAppliersCollection(source.Property, destination.Property);
            UnionWithAppliersCollection(source.PropertyPath, destination.PropertyPath);

            UnionWithAppliersCollection(source.ManyToOne, destination.ManyToOne);
            UnionWithAppliersCollection(source.ManyToOnePath, destination.ManyToOnePath);

            UnionWithAppliersCollection(source.OneToOne, destination.OneToOne);
            UnionWithAppliersCollection(source.OneToOnePath, destination.OneToOnePath);

            UnionWithAppliersCollection(source.Any, destination.Any);
            UnionWithAppliersCollection(source.AnyPath, destination.AnyPath);

            UnionWithAppliersCollection(source.Collection, destination.Collection);
            UnionWithAppliersCollection(source.CollectionPath, destination.CollectionPath);
            UnionWithAppliersCollection(source.Bag, destination.Bag);
            UnionWithAppliersCollection(source.BagPath, destination.BagPath);
            UnionWithAppliersCollection(source.List, destination.List);
            UnionWithAppliersCollection(source.ListPath, destination.ListPath);
            UnionWithAppliersCollection(source.Set, destination.Set);
            UnionWithAppliersCollection(source.SetPath, destination.SetPath);
            UnionWithAppliersCollection(source.Map, destination.Map);
            UnionWithAppliersCollection(source.MapPath, destination.MapPath);

            UnionWithAppliersCollection(source.ComponentParent, destination.ComponentParent);

            UnionWithAppliersCollection(source.ManyToMany, destination.ManyToMany);
            UnionWithAppliersCollection(source.ManyToManyPath, destination.ManyToManyPath);

            UnionWithAppliersCollection(source.Element, destination.Element);
            UnionWithAppliersCollection(source.ElementPath, destination.ElementPath);

            UnionWithAppliersCollection(source.OneToMany, destination.OneToMany);
            UnionWithAppliersCollection(source.OneToManyPath, destination.OneToManyPath);

            UnionWithAppliersCollection(source.MapKeyManyToMany, destination.MapKeyManyToMany);
            UnionWithAppliersCollection(source.MapKeyManyToManyPath, destination.MapKeyManyToManyPath);

            UnionWithAppliersCollection(source.MapKey, destination.MapKey);
            UnionWithAppliersCollection(source.MapKeyPath, destination.MapKeyPath);
        }
        public void CallSpecificAppliersOnSet()
        {
            var patternAppliers = new EmptyPatternsAppliersHolder();

            var applier = new Mock<IPatternApplier<MemberInfo, ISetPropertiesMapper>>();
            applier.Setup(x => x.Match(It.IsAny<MemberInfo>())).Returns(true);
            patternAppliers.Set.Add(applier.Object);

            var mapper = new Mapper(domainInspectorMock.Object, patternAppliers);
            mapper.CompileMappingFor(new[] { typeof(MyClass) });

            applier.Verify(x => x.Apply(It.Is<MemberInfo>(pp => pp.Name == "Set"), It.IsAny<ISetPropertiesMapper>()));
        }