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 SamopalDISeeCommentsIntTest08() { var di = new SamopalDI(); di.BindExample <IClass5>(100500, (args) => new Class5((string)args[0])); // here is the source of problems // IClass3 is binding to example 1, not to Default, // and IClass2 isn't get IClass3 instance by correct delegate di.BindExample <IClass2, Class2>(1456); 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!" }; Assert.ThrowsException <ArgumentException>(() => di.GetExample <IClass1>(-100600, arrayOfArgs)); }
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); }
public TenClassesController( IClass1 classA, IClass2 classB, IClass3 classC, IClass4 classD, IClass5 classE, IClass6 classF, IClass7 classG, IClass8 classH, IClass9 classI, IClass10 classJ ) { this.classA = classA; this.classB = classB; this.classC = classC; this.classD = classD; this.classE = classE; this.classF = classF; this.classG = classG; this.classH = classH; this.classI = classI; this.classJ = classJ; }
public HundredClassesController( IClass1 class1, IClass2 class2, IClass3 class3, IClass4 class4, IClass5 class5, IClass6 class6, IClass7 class7, IClass8 class8, IClass9 class9, IClass10 class10, IClass11 class11, IClass12 class12, IClass13 class13, IClass14 class14, IClass15 class15, IClass16 class16, IClass17 class17, IClass18 class18, IClass19 class19, IClass20 class20, IClass21 class21, IClass22 class22, IClass23 class23, IClass24 class24, IClass25 class25, IClass26 class26, IClass27 class27, IClass28 class28, IClass29 class29, IClass30 class30, IClass31 class31, IClass32 class32, IClass33 class33, IClass34 class34, IClass35 class35, IClass36 class36, IClass37 class37, IClass38 class38, IClass39 class39, IClass40 class40, IClass41 class41, IClass42 class42, IClass43 class43, IClass44 class44, IClass45 class45, IClass46 class46, IClass47 class47, IClass48 class48, IClass49 class49, IClass50 class50, IClass51 class51, IClass52 class52, IClass53 class53, IClass54 class54, IClass55 class55, IClass56 class56, IClass57 class57, IClass58 class58, IClass59 class59, IClass60 class60, IClass61 class61, IClass62 class62, IClass63 class63, IClass64 class64, IClass65 class65, IClass66 class66, IClass67 class67, IClass68 class68, IClass69 class69, IClass70 class70, IClass71 class71, IClass72 class72, IClass73 class73, IClass74 class74, IClass75 class75, IClass76 class76, IClass77 class77, IClass78 class78, IClass79 class79, IClass80 class80, IClass81 class81, IClass82 class82, IClass83 class83, IClass84 class84, IClass85 class85, IClass86 class86, IClass87 class87, IClass88 class88, IClass89 class89, IClass90 class90, IClass91 class91, IClass92 class92, IClass93 class93, IClass94 class94, IClass95 class95, IClass96 class96, IClass97 class97, IClass98 class98, IClass99 class99, IClass100 class100 ) { this.class1 = class1; this.class2 = class2; this.class3 = class3; this.class4 = class4; this.class5 = class5; this.class6 = class6; this.class7 = class7; this.class8 = class8; this.class9 = class9; this.class10 = class10; this.class11 = class11; this.class12 = class12; this.class13 = class13; this.class14 = class14; this.class15 = class15; this.class16 = class16; this.class17 = class17; this.class18 = class18; this.class19 = class19; this.class20 = class20; this.class21 = class21; this.class22 = class22; this.class23 = class23; this.class24 = class24; this.class25 = class25; this.class26 = class26; this.class27 = class27; this.class28 = class28; this.class29 = class29; this.class30 = class30; this.class31 = class31; this.class32 = class32; this.class33 = class33; this.class34 = class34; this.class35 = class35; this.class36 = class36; this.class37 = class37; this.class38 = class38; this.class39 = class39; this.class40 = class40; this.class41 = class41; this.class42 = class42; this.class43 = class43; this.class44 = class44; this.class45 = class45; this.class46 = class46; this.class47 = class47; this.class48 = class48; this.class49 = class49; this.class50 = class50; this.class51 = class51; this.class52 = class52; this.class53 = class53; this.class54 = class54; this.class55 = class55; this.class56 = class56; this.class57 = class57; this.class58 = class58; this.class59 = class59; this.class60 = class60; this.class61 = class61; this.class62 = class62; this.class63 = class63; this.class64 = class64; this.class65 = class65; this.class66 = class66; this.class67 = class67; this.class68 = class68; this.class69 = class69; this.class70 = class70; this.class71 = class71; this.class72 = class72; this.class73 = class73; this.class74 = class74; this.class75 = class75; this.class76 = class76; this.class77 = class77; this.class78 = class78; this.class79 = class79; this.class80 = class80; this.class81 = class81; this.class82 = class82; this.class83 = class83; this.class84 = class84; this.class85 = class85; this.class86 = class86; this.class87 = class87; this.class88 = class88; this.class89 = class89; this.class90 = class90; this.class91 = class91; this.class92 = class92; this.class93 = class93; this.class94 = class94; this.class95 = class95; this.class96 = class96; this.class97 = class97; this.class98 = class98; this.class99 = class99; this.class100 = class100; }
public Class4(IClass5 class5) { Class5 = class5; }