public void BootstrappingUsingAssemblyParamListShouldContainTypesInParamList() { var sut = new CatalogBootstrapper(); sut.Should().NotBeNull(); sut.AssemblyNamingConvention.Should().BeNull(); sut.UseAssemblyNamingConvention.Should().Be(false); var result = sut.Bootstrap(null, typeof(Samples.Business.BusinessDependencyRegistrar).Assembly, typeof(Samples.Data.DataDependencyRegistrar).Assembly); result.Should().NotBeNull(); result.Catalogs.Should().HaveCount(c => c > 0); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.TestApplicationDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Business.BusinessDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.DataDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.Foo"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Business.CustomerService"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.CustomerRepository"); }
public void BootstrappingUsingCatalogAndConventionShouldIncludeTestAndSampleParts() { // Build pre-wired assembly catalog RegistrationBuilder conventions = new RegistrationBuilder(); conventions.ForTypesDerivedFrom<IApplicationDependencyRegistrar>() .SetCreationPolicy(CreationPolicy.Shared) .ExportInterfaces() .Export(); var catalog = new AssemblyCatalog(typeof(CatalogBootstrapperTest).Assembly, conventions); var sut = new CatalogBootstrapper("Samples*.dll", catalog); sut.Should().NotBeNull(); var result = sut.Bootstrap(); result.Should().NotBeNull(); // Registrars result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.TestApplicationDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Business.BusinessDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.DataDependencyRegistrar"); // Test/Sample types result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.Foo"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Business.CustomerService"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.CustomerRepository"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.SampleConnectionFactory"); }
public void PassingOnlyCatalogToCtorShouldSetUseAssemblyNamingConventionToFalse() { var catalog = new AssemblyCatalog(typeof(CatalogBootstrapperTest).Assembly); var sut = new CatalogBootstrapper(null, catalog); sut.Should().NotBeNull(); sut.AssemblyNamingConvention.Should().BeNull(); sut.UseAssemblyNamingConvention.Should().Be(false); }
public void UsingEmptyCtorShouldSetUseAssemblyNamingConventionToFalse() { var sut = new CatalogBootstrapper(); sut.Should().NotBeNull(); sut.UseAssemblyNamingConvention.Should().Be(false); }
public void PassingOnlyAConventionToCtorShouldSetUseAssemblyNamingConventionToTrue() { var sut = new CatalogBootstrapper(assemblyExpression); sut.Should().NotBeNull(); sut.UseAssemblyNamingConvention.Should().Be(true); }
public void ExpressionPassedToConventionCtorShouldMatchAssemblyNamingConvention() { var sut = new CatalogBootstrapper(assemblyExpression); sut.Should().NotBeNull(); sut.AssemblyNamingConvention.Should().Be(assemblyExpression); }
public void BootstrappingWithoutApplicationDependencyRegistrarShouldThrowException() { var sut = new CatalogBootstrapper("Foo*.dll"); sut.Should().NotBeNull(); var result = sut.Bootstrap(); }
public void BootstrappingUsingOnlyConventionShouldOnlyIncludeTestAssemblyTypes() { var sut = new CatalogBootstrapper(assemblyExpression); sut.Should().NotBeNull(); var result = sut.Bootstrap(); result.Should().NotBeNull(); result.Catalogs.Should().HaveCount(c => c > 0); // Registrar types result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.TestApplicationDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().NotContain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Business.BusinessDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().NotContain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.DataDependencyRegistrar"); // Test POCO type result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.Foo"); }
public void BootstrappingUsingOnlyCatalogShouldIncludeTestAndSampleTypes() { var catalog = new AssemblyCatalog(typeof(CatalogBootstrapperTest).Assembly); var sut = new CatalogBootstrapper(null, catalog); sut.Should().NotBeNull(); var result = sut.Bootstrap(); result.Should().NotBeNull(); result.Catalogs.Should().HaveCount(c => c > 0); // Registrars result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.TestApplicationDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Business.BusinessDependencyRegistrar"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.DataDependencyRegistrar"); // Test/Sample types result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Heliar.Composition.Core.Tests.Foo"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Business.CustomerService"); result.Catalogs.SelectMany(c => c.Parts).Should().Contain(p => (p as System.ComponentModel.Composition.Primitives.ICompositionElement).DisplayName == "Samples.Data.CustomerRepository"); }