public void SamopalDISeeCommentsIntTest05() { var di = new SamopalDI(); di.BindDefault <IClass5>((args) => new Class5((string)args[0])); di.BindDefault <IClass2, Class2>(); di.BindDefault <IClass3, Class3>(); di.BindDefault <IClass4>((args) => { IClass5 c5 = di.GetDefault <IClass5>(args); return(new Class4(c5)); }); di.BindDefault <IClass1>((args) => { IClass2 c2 = di.GetDefault <IClass2>(); IClass4 c4 = di.GetDefault <IClass4>(args); return(new Class1(c2, c4)); }); object[] arrayOfArgs = new object[] { "Hello, Test!" }; Type expected = typeof(Class1); IClass1 variable = di.GetDefault <IClass1>(arrayOfArgs); Type actual = variable.GetType(); Assert.AreEqual(expected, actual); Assert.AreEqual("Hello, Test!", variable.Class4.Class5.SomeString); Assert.IsNotNull(variable.Class2.Class3); }
public void SamopalDISeeCommentsIntTest03() { var di = new SamopalDI(); di.BindDefault <IClass5>((args) => new Class5("Hello, Test!")); di.BindDefault <IClass2, Class2>(); di.BindDefault <IClass3, Class3>(); di.BindDefault <IClass4, Class4>(); di.BindDefault <IClass1, Class1>(); Type expected = typeof(Class1); IClass1 variable = di.GetDefault <IClass1>(); Type actual = variable.GetType(); Assert.AreEqual(expected, actual); Assert.AreEqual("Hello, Test!", variable.Class4.Class5.SomeString); }
public void SamopalDISeeCommentsIntTest09() { var di = new SamopalDI(); di.BindExample <IClass5>(100500, (args) => new Class5((string)args[0])); // now we'll get IClass4 example instance by correct delegate di.BindExample <IClass2>(1456, (args) => { IClass3 class3 = di.GetExample <IClass3>(3334445); return(new Class2(class3)); }); di.BindExample <IClass3, Class3>(3334445); di.BindExample <IClass4>(1, (args) => { IClass5 c5 = di.GetExample <IClass5>(100500, args); return(new Class4(c5)); }); di.BindExample <IClass1>(-100600, (args) => { IClass2 c2 = di.GetExample <IClass2>(1456); IClass4 c4 = di.GetExample <IClass4>(1, args); return(new Class1(c2, c4)); }); object[] arrayOfArgs = new object[] { "Hello, Test!" }; Type expected = typeof(Class1); IClass1 variable = di.GetExample <IClass1>(-100600, arrayOfArgs); Type actual = variable.GetType(); Assert.AreEqual(expected, actual); Assert.AreEqual("Hello, Test!", variable.Class4.Class5.SomeString); Assert.IsNotNull(variable.Class2.Class3); }