public void ShouldUseRuntimeImplementationTypeWhenMultipleImplementationsAvailable() { store.SetImplementationType(typeof(InterfaceWithMultipleImplementations), typeof(MultiImplOne)); ClassThatDependsOnMultiImplInterface constructed = (ClassThatDependsOnMultiImplInterface)store.GetByType(typeof(ClassThatDependsOnMultiImplInterface)); Assert.IsNotNull(constructed); Assert.IsNotNull(constructed.Dependency); Assert.IsTrue(constructed.Dependency is MultiImplOne); }
public void ShouldBeAbleToSetupDependencyImplementationsForIdentifiers() { store.AddTypeForName("foo", typeof(ClassThatDependsOnMultiImplInterface)); store.SetDependencyImplementationForName("foo", typeof(InterfaceWithMultipleImplementations), typeof(MultiImplTwo)); ClassThatDependsOnMultiImplInterface constructed = (ClassThatDependsOnMultiImplInterface)store.GetByName("foo"); Assert.IsNotNull(constructed); Assert.IsNotNull(constructed.Dependency); Assert.IsTrue(constructed.Dependency is MultiImplTwo); }
public void ShouldBeAbleToAddDecoratorsForAGivenIdentifiedImplementation() { store.AddTypeForName("foo", typeof(MultiImplOne)).Decorate(typeof(DecoratingMultiImpl)).Decorate(typeof(ClassThatDependsOnMultiImplInterface)); ClassThatDependsOnMultiImplInterface constructed = (ClassThatDependsOnMultiImplInterface)store.GetByName("foo"); Assert.IsNotNull(constructed); Assert.IsNotNull(constructed.Dependency); Assert.IsTrue(constructed.Dependency is DecoratingMultiImpl); Assert.IsNotNull(((DecoratingMultiImpl)constructed.Dependency).Dependency); Assert.IsTrue(((DecoratingMultiImpl)constructed.Dependency).Dependency is MultiImplOne); }
public void ShouldBeAbleToAddDecoratorsForAGivenIdentifiedInstance() { MultiImplOne instance = new MultiImplOne(); store.AddInstanceForName("foo", instance).Decorate(typeof(DecoratingMultiImpl)).Decorate(typeof(ClassThatDependsOnMultiImplInterface)); ClassThatDependsOnMultiImplInterface constructed = (ClassThatDependsOnMultiImplInterface)store.GetByName("foo"); Assert.IsNotNull(constructed); Assert.IsNotNull(constructed.Dependency); Assert.IsTrue(constructed.Dependency is DecoratingMultiImpl); Assert.IsNotNull(((DecoratingMultiImpl)constructed.Dependency).Dependency); Assert.AreSame(instance, ((DecoratingMultiImpl)constructed.Dependency).Dependency); }