Example #1
0
        public void DependencyContainerTest()
        {
            DependencyConfig config     = new DependencyConfig();
            Parameters       parameters = new Parameters();

            parameters.Add("StringProperty2", "Test");
            config.Define(typeof(DITestInterface), typeof(DITestInterfaceImpl));
            DependencyContainer container = new DependencyContainer(config);
            var obj = new DITestClass();

            container.ResolveDependencies(obj, parameters);

            Assert.True(obj.StringProperty2.Equals("Test"));
            Assert.True(obj.InterfaceProperty.GetType().Equals(typeof(DITestInterfaceImpl)));
        }
Example #2
0
        public void ResolveDependenciesTest()
        {
            Parameters param = new Parameters();

            param.Add("StringProperty1", "Hello");
            param.Add("StringProperty2", "Hello again");
            var obj = new DITestClass();
            DependencyContainer container = new DependencyContainer();

            container.ResolveDependencies(obj, param);

            Assert.True(obj.StringProperty.Equals("Hello"));
            Assert.True(obj.StringProperty2.Equals("Hello again"));
            Assert.True(obj.StringProperty3 == null);
        }