public void Interfaces_registered_in_the_container_after_wrapping_it_with_ObjectBuilder_are_resolvable_via_builder() { var container = new UnityContainer(); var builder = new UnityObjectBuilder(container); container.RegisterType <ISomeInterface, SomeClass>(); var result = builder.Build(typeof(ISomeInterface)); Assert.IsInstanceOf <SomeClass>(result); }
public void Concrete_classes_registered_in_plain_container_are_resolvable_via_builder() { var container = new UnityContainer(); container.RegisterType <SomeClass>(); var builder = new UnityObjectBuilder(container); var result = builder.Build(typeof(SomeClass)); Assert.IsInstanceOf <SomeClass>(result); }
public void Existing_instances_registred_in_the_container_can_be_injected_via_constructor() { var container = new UnityContainer(); var builder = new UnityObjectBuilder(container); builder.Configure(typeof(ConstructorInjectionHandler), DependencyLifecycle.InstancePerCall); container.RegisterInstance <ISomeInterface>(new SomeClass()); var result = (ConstructorInjectionHandler)builder.Build(typeof(ConstructorInjectionHandler)); Assert.IsNotNull(result.Dependency); }
public void It_should_be_created_as_a_single_instance() { var conainer = new UnityContainer(); conainer.RegisterType <Root, Root>(); conainer.RegisterType <ServiceA, ServiceA>(new PerResolveLifetimeManager()); conainer.RegisterType <ServiceB, ServiceB>(); using (var builder = new UnityObjectBuilder(conainer)) { var root = (Root)builder.Build(typeof(Root)); Assert.AreSame(root.ServiceA, root.ServiceB.ServiceA); } }