public void RegisterWithClassNotImplementsInterface() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass)); di.Register(typeof(MyClass2), typeof(IClass3)); }
public void RegisterTwoTimesToInterface() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass)); di.Register(typeof(MyClass), typeof(IClass)); }
public void RegisterTwoTimesToItself() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass)); di.Register(typeof(MyClass)); }
public void InjectionFailDependencyNotFound() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass)); di.Register(typeof(MyClass3), typeof(IClass3)); TestClass testClass = di.CallCtor(typeof(TestClass)) as TestClass; }
public void InjectionGood() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass)); di.Register(typeof(MyClass2), typeof(IClass2)); TestClass testClass = di.CallCtor(typeof(TestClass)) as TestClass; Assert.AreEqual(true, testClass.IsGood); }
public void PropertyInjectionGood() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass)); di.Register(typeof(MyClass2), typeof(IClass2)); TestClass2 testClass = di.CreateAndPropInjection(typeof(TestClass2)) as TestClass2; Assert.AreEqual(true, testClass.Property1.IsEnabled); Assert.AreEqual(true, testClass.Property2.IsEnabled); }
public void RegisterAndResolveTwoClassesToInterface() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass)); di.Register(typeof(MyClass2), typeof(IClass2)); IClass iClass = di.Resolve(typeof(MyClass), typeof(IClass)) as MyClass; IClass2 iClass2 = di.Resolve(typeof(MyClass2), typeof(IClass2)) as MyClass2; Assert.AreEqual(true, iClass.IsEnabled); Assert.AreEqual(true, iClass2.IsEnabled); }
public void RegisterAndResolveToItself() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass)); MyClass myClass = di.Resolve(typeof(MyClass)) as MyClass; Assert.AreEqual(true, myClass.IsEnabled); }
public void RegisterAndResolveWithNotExistedInterface() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass)); IClass iClass = di.Resolve(typeof(MyClass), typeof(IClass2)) as MyClass; Assert.AreEqual(null, iClass); }
public void RegisterAndResolveWithKey() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(IClass), "key"); IClass iClass = di.Resolve(typeof(MyClass), "key") as MyClass; Assert.AreEqual(true, iClass.IsEnabled); }
public void InvalidInterfaceTypeTest() { SimpleDependencyInjector di = new SimpleDependencyInjector(); di.Register(typeof(MyClass), typeof(MyClass)); }