public void Bind_ToStrategy_Strategy_Is_Disposed_With_Container() { var strategy = new TestBindingStrategy<Bar1>(() => new Bar1()); ComponentContainer container = new ComponentContainer(); container.Bind<IBar>().ToStrategy(strategy); container.Dispose(); Assert.IsTrue(strategy.DisposeWasCalled); }
public void Bind_ToStrategy_Calls_Strategy() { var strategy = new TestBindingStrategy<Bar1>(() => new Bar1()); ComponentContainer container = new ComponentContainer(); container.Bind<IBar>().ToStrategy(strategy); var bar = container.Resolve<IBar>(); Assert.IsTrue(strategy.ResolveWasCalled); }
public void Bind_ToStrategy_Where_Strategy_Returns_Null_Throws_Exception() { var strategy = new TestBindingStrategy<Bar1>(() => null); ComponentContainer container = new ComponentContainer(); container.Bind<IBar>().ToStrategy(strategy); var bar = container.Resolve<IBar>(); }
public void Rebind_Calls_Dispose_On_Old_Binding() { var strategy = new TestBindingStrategy<IBar>(() => new Bar1()); ComponentContainer container = new ComponentContainer(); container.Bind<IBar>().ToStrategy(strategy); container.Rebind<IBar>().To<Bar2>(); Assert.IsTrue(strategy.DisposeWasCalled); }
public void Bind_ToStrategy_Where_Strategy_Returns_Wrong_Type_Throws_Exception() { var strategy = new TestBindingStrategy<HasOneImplementor>(() => new HasOneImplementor()); ComponentContainer container = new ComponentContainer(); container.Bind<IBar>().ToStrategy(strategy); var bar = container.Resolve<IBar>(); }