public void ManyConstructorsControllerFindLongestConstructor_ShouldSucceed()
        {
            var ctx = new RegistrationBuilder();

            ctx.ForType <FormsAuthenticationServiceImpl>().Export <IFormsAuthenticationService>();
            ctx.ForType <HttpDigestAuthentication>().Export <IAuthentication>();
            ctx.ForType <MembershipServiceImpl>().Export <IMembershipService>();
            ctx.ForType <HttpRequestValidator>().Export();
            ctx.ForType <ManyConstructorsController>().Export();

            var catalog = new TypeCatalog(new[] {
                typeof(FormsAuthenticationServiceImpl),
                typeof(HttpDigestAuthentication),
                typeof(MembershipServiceImpl),
                typeof(HttpRequestValidator),
                typeof(ManyConstructorsController)
            }, ctx);

            Assert.True(catalog.Parts.Count() == 5);

            var container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);
            ManyConstructorsController item = container.GetExportedValue <ManyConstructorsController>();

            Assert.True(item.Validator != null);
            Assert.True(item.FormsService != null);
            Assert.True(item.MembershipService != null);
        }
        public void ManyConstructorsControllerFindLongestConstructorAndImportByName_ShouldSucceed()
        {
            var ctx = new RegistrationBuilder();

            ctx.ForType<FormsAuthenticationServiceImpl>().Export<IFormsAuthenticationService>();
            ctx.ForType<HttpDigestAuthentication>().Export<IAuthentication>();
            ctx.ForType<MembershipServiceImpl>().Export<IMembershipService>();
            ctx.ForType<SpecificMembershipServiceImpl>().Export<IMembershipService>((c) => c.AsContractName("membershipService"));
            ctx.ForType<HttpRequestValidator>().Export();
            ctx.ForType<ManyConstructorsController>().SelectConstructor(null, (pi, import) =>
           {
               if (typeof(IMembershipService).IsAssignableFrom(pi.ParameterType))
               {
                   import.AsContractName("membershipService");
               }
           }).Export();

            var catalog = new TypeCatalog(new[] {
                typeof(FormsAuthenticationServiceImpl),
                typeof(HttpDigestAuthentication),
                typeof(MembershipServiceImpl),
                typeof(SpecificMembershipServiceImpl),
                typeof(HttpRequestValidator),
                typeof(ManyConstructorsController) }, ctx);

            Assert.True(catalog.Parts.Count() == 6);

            var container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);
            ManyConstructorsController item = container.GetExportedValue<ManyConstructorsController>();

            Assert.True(item.Validator != null);
            Assert.True(item.FormsService != null);
            Assert.True(item.MembershipService != null);
            Assert.True(item.MembershipService.GetType() == typeof(SpecificMembershipServiceImpl));
        }