public void Shared() { var parts = new[] { typeof(IHelloWorldShared), typeof(HelloWorldShared) }.AsApplicationParts(); var container = new ContainerConfiguration().WithParts( parts.ToArray(), ConventionBuilderFactory.Default.Get() ).CreateContainer(); var export = container.GetExport<IHelloWorldShared>(); Assert.IsType<HelloWorldShared>( export ); Assert.Same( export, container.GetExport<IHelloWorldShared>() ); Assert.Same( container.GetExport<HelloWorldShared>(), container.GetExport<HelloWorldShared>() ); Assert.Same( container.GetExport<HelloWorldShared>(), container.GetExport<IHelloWorldShared>() ); }
public void WithoutConvention() { var parts = new[] { typeof(IHelloWorld), typeof(HelloWorld) }.AsApplicationParts(); var container = new ContainerConfiguration().WithParts( parts.ToArray() ).CreateContainer(); Assert.Throws<CompositionFailedException>( () => container.GetExport<IHelloWorld>() ); }