public void Bind_Duplicate_Anonymous() { DIContainer container = new DIContainer(); container.Bind <TestClass>(); container.Bind <TestClass>(); }
public void Bind_Multiple_WithID([Range(-10000, 10000, 1000)] int id) { DIContainer container = new DIContainer(); container.Bind <TestClass>(id); container.Bind <TestClass>(id + 1); }
public void Bind_Duplicate_Anonymous() { DIContainer container = new DIContainer(); container.Bind <TestClass>(); Assert.Throws <ArgumentException>(() => container.Bind <TestClass>()); }
public void Bind_Duplicate_WithID([Range(-10000, 10000, 1000)] int id) { DIContainer container = new DIContainer(); container.Bind <TestClass>(id); Assert.Throws <ArgumentException>(() => container.Bind <TestClass>(id)); }
public void Inject_SingleViaBind([Values("TestID")] string id) { DIContainer container = new DIContainer(); InjectTestClassA testClass = new InjectTestClassA(); container.Bind(id); container.Bind(testClass); container.FlushInjectQueue(); Assert.AreEqual(testClass.ID, id); }
public void Inject_Field_SingleViaBind([Values("TestID")] string id) { DIContainer container = new DIContainer(); var testClass = new FieldInjectTestClassGeneric <string>(); container.Bind(id); container.Bind(testClass); container.FlushInjectQueue(); Assert.AreEqual(testClass.Value, id); }
public void Inject_MultipleViaManualInject([Values("Value1")] string value1, [Values("Value2")] string value2) { DIContainer container = new DIContainer(); InjectTestClassB testClass = new InjectTestClassB(); container.Bind(value1, 1); container.Bind(value2, 2); container.Inject(testClass); Assert.AreEqual(testClass.Value1, value1); Assert.AreEqual(testClass.Value2, value2); }
public void Inject_Method_MultipleViaInjectQueue([Values("Value1")] string value1, [Values("Value2")] string value2) { DIContainer container = new DIContainer(); MethodInjectTestClass testClass = new MethodInjectTestClass(); container.Bind(value1, 1); container.Bind(value2, 2); container.QueueForInject(testClass); container.FlushInjectQueue(); Assert.AreEqual(testClass.Value1, value1); Assert.AreEqual(testClass.Value2, value2); }
public void Inject_Field_MultipleViaBind([Values("Value1")] string value1, [Values("Value2")] string value2) { DIContainer container = new DIContainer(); var testClass = new FieldInjectTestClass(); container.Bind(value1, 1); container.Bind(value2, 2); container.Bind(testClass); container.FlushInjectQueue(); Assert.AreEqual(testClass.Value1, value1); Assert.AreEqual(testClass.Value2, value2); }
public void Bind_Instance_Anonymous() { TestClass testObj = new TestClass() { m_id = "Test" }; DIContainer container = new DIContainer(); container.Bind(testObj); }
public void Get_Multiple_WithVaryingIDs([Range(-10000, 10000, 1000)] int initialID) { TestClass testObj1 = new TestClass() { m_id = "Test1" }; TestClass testObj2 = new TestClass() { m_id = "Test2" }; DIContainer container = new DIContainer(); container.Bind(testObj1, initialID++); container.Bind(testObj2, initialID); var bindings = container.GetAll <TestClass>(); Assert.IsTrue(bindings.Count == 2); }
public void Inject_Method_SingleViaManualInject([Values("TestID")] string id) { DIContainer container = new DIContainer(); var testClass = new MethodInjectTestClassGeneric <string>(); container.Bind(id); container.Inject(testClass); Assert.AreEqual(testClass.Value, id); }
public void Bind_Instance_WithID([Range(-10000, 10000, 1000)] int id) { TestClass testObj = new TestClass() { m_id = "Test" }; DIContainer container = new DIContainer(); container.Bind(testObj); }
public void Get_Multiple_Anonymous() { TestClass testObj1 = new TestClass() { m_id = "Test1" }; TestClass testObj2 = new TestClass() { m_id = "Test2" }; DIContainer container = new DIContainer(); container.Bind(testObj1); container.Bind(testObj2); var bindings = container.GetAll <TestClass>(); Assert.IsTrue(bindings.Count == 2); }
public void Get_WithID([Range(-10000, 10000, 1000)] int id) { TestClass testObj = new TestClass() { m_id = "Test" }; DIContainer container = new DIContainer(); container.Bind(testObj, id); Assert.AreEqual(testObj, container.Get <TestClass>(id)); }
public void Get_Anonymous() { TestClass testObj = new TestClass() { m_id = "Test" }; DIContainer container = new DIContainer(); container.Bind(testObj); Assert.AreEqual(testObj, container.Get <TestClass>()); }
private void Application_Startup(object sender, StartupEventArgs e) { IContainerCore container = new DIContainer(new ServiceModule()); IControllerCore controller = new ControllerCore(new ViewModule(), container); container.Bind <IControllerCore>().ToInstance(controller); Window window = controller.ViewFactory.GetWindow <MainView>(); window.Show(); }
public void Inject_Field_All_Enumerable(params int[] values) { DIContainer container = new DIContainer(); FieldInjectTestClassGeneric <IEnumerable <int> > testClass = new FieldInjectTestClassGeneric <IEnumerable <int> >(); foreach (var value in values) { container.Bind(value); } container.Inject(testClass); Assert.AreEqual(testClass.Value.Count(), values.Length); }
public void Inject_Method_All_List(params int[] values) { DIContainer container = new DIContainer(); MethodInjectTestClassGeneric <List <int> > testClass = new MethodInjectTestClassGeneric <List <int> >(); foreach (var value in values) { container.Bind(value); } container.Inject(testClass); Assert.AreEqual(testClass.Value.Count, values.Length); for (int i = 0; i < values.Length; i++) { Assert.AreEqual(testClass.Value[i], values[i]); } }
public override void InstallBindings(DIContainer container) { container.Bind <Factory>(); }
public override void InstallBindings(DIContainer container) { container.Bind(m_value); container.Bind(m_value2, 2); }
public override void InstallBinding() { DIContainer.Bind <TempInterface, NewClass>(); DIContainer.Bind <AnotherInterface, AnotherClass>(); }