public void DoesBootstrapBindings() { Container container = new Container(); container.Bootstrap <SomeBootstrap>(); ISomeTypeTwo two = container.Resolve <ISomeTypeTwo>(); Assert.IsNotNull(two); }
public void DoesResolveTypeWithObjectCategoryUsingResolveWithCategory() { Container container = new Container(); byte category = 123; container.Bind <ISomeTypeTwo>().To <SomeTypeTwo>().WithCategory(category); ISomeTypeTwo two = container.ResolveWithCategory <ISomeTypeTwo>(category); Assert.IsNotNull(two); container = null; }
public void DoesResolveFromInheritedContainer() { Container containerA = new Container(); Container containerB = new Container(); containerA.Bind <ISomeTypeTwo>().To <SomeTypeTwo>().AsSingleton(); containerB.Inherit(containerA); containerB.Bind <ISomeTypeOne>().To <SomeTypeOne>().AsSingleton(); ISomeTypeOne one = containerB.Resolve <ISomeTypeOne>(); ISomeTypeTwo two = containerA.Resolve <ISomeTypeTwo>(); //Assert.IsNotNull(one); //Assert.IsNotNull(one.Two); Assert.AreEqual(one.Two, two); }
public void DoesOverrideInheritedBindingWhenBoundAsSingleton() { Container containerA = new Container(); Container containerB = new Container(); containerA.Bind <ISomeTypeOne>().To <SomeTypeOne>().AsTransient(); containerA.Bind <ISomeTypeTwo>().To <SomeTypeTwo>().AsSingleton(); containerB.Inherit(containerA); containerB.Bind <ISomeTypeTwo>().To <AnotherTypeTwo>().AsSingleton(); ISomeTypeOne one = containerB.Resolve <ISomeTypeOne>(); Assert.IsNotNull(one.Two, "two did not resolve"); Assert.IsInstanceOfType(one.Two, typeof(AnotherTypeTwo), "ContainerB did not override inhjected type"); ISomeTypeTwo two = containerB.Resolve <ISomeTypeTwo>(); Assert.AreEqual(two, one.Two, "Did not resolve singleton instance"); Assert.IsInstanceOfType(two, typeof(AnotherTypeTwo), "ContainerB did not override inhjected type"); }
public void DoesResolveSingleton() { Container container = new Container(); // Transient & Singleton binding... container.Bind <ISomeTypeOne>().To <SomeTypeOne>(); container.Bind <ISomeTypeTwo>().To <SomeTypeTwo>().AsSingleton(); // Resolve one... should be injected ISomeTypeOne one = container.Resolve <ISomeTypeOne>(); Assert.IsNotNull(one); Assert.IsNotNull(one.Two); // Resolve singleton ISomeTypeTwo twoTest2 = container.Resolve <ISomeTypeTwo>(); Assert.AreEqual(one.Two, twoTest2); container = null; }
SomeTypeOne(ISomeTypeTwo two) { Two = two; }