예제 #1
0
        public void Bind_Duplicate_Anonymous()
        {
            DIContainer container = new DIContainer();

            container.Bind <TestClass>();
            container.Bind <TestClass>();
        }
예제 #2
0
        public void Bind_Multiple_WithID([Range(-10000, 10000, 1000)] int id)
        {
            DIContainer container = new DIContainer();

            container.Bind <TestClass>(id);
            container.Bind <TestClass>(id + 1);
        }
예제 #3
0
        public void Bind_Duplicate_Anonymous()
        {
            DIContainer container = new DIContainer();

            container.Bind <TestClass>();

            Assert.Throws <ArgumentException>(() => container.Bind <TestClass>());
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        public void Bind_Instance_Anonymous()
        {
            TestClass testObj = new TestClass()
            {
                m_id = "Test"
            };
            DIContainer container = new DIContainer();

            container.Bind(testObj);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        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));
        }
예제 #16
0
        public void Get_Anonymous()
        {
            TestClass testObj = new TestClass()
            {
                m_id = "Test"
            };
            DIContainer container = new DIContainer();

            container.Bind(testObj);
            Assert.AreEqual(testObj, container.Get <TestClass>());
        }
예제 #17
0
        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();
        }
예제 #18
0
        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);
        }
예제 #19
0
        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]);
            }
        }
예제 #20
0
 public override void InstallBindings(DIContainer container)
 {
     container.Bind <Factory>();
 }
예제 #21
0
 public override void InstallBindings(DIContainer container)
 {
     container.Bind(m_value);
     container.Bind(m_value2, 2);
 }
예제 #22
0
 public override void InstallBinding()
 {
     DIContainer.Bind <TempInterface, NewClass>();
     DIContainer.Bind <AnotherInterface, AnotherClass>();
 }