Exemplo n.º 1
0
        public void BuildUpTests_BuildUp()
        {
            using (var container = new StashboxContainer())
            {
                container.Register <ITest, Test>();

                var test1 = new Test1();
                container.WireUpAs <ITest1>(test1);

                var test2 = new Test2();
                var inst  = container.BuildUp(test2);

                Assert.AreEqual(test2, inst);
                Assert.IsNotNull(inst);
                Assert.IsNotNull(inst.Test1);
                Assert.IsInstanceOfType(inst, typeof(Test2));
                Assert.IsInstanceOfType(inst.Test1, typeof(Test1));
                Assert.IsInstanceOfType(inst.Test1.Test, typeof(Test));
            }
        }
Exemplo n.º 2
0
        public void ResolveFactoryTests_ThreeParams_Scoped()
        {
            using (var container = new StashboxContainer())
            {
                container.Register <Test3>();

                using (var scope = container.BeginScope())
                {
                    var factory = scope.ResolveFactory <Test, Test1, Test2, Test3>();

                    var test  = new Test();
                    var test1 = new Test1(test);
                    var test2 = new Test2(test1, test);
                    var inst  = factory(test, test1, test2);

                    Assert.AreSame(test, inst.Test);
                    Assert.AreSame(test1, inst.Test1);
                    Assert.AreSame(test2, inst.Test2);
                }
            }
        }
Exemplo n.º 3
0
 public Test4(Test2 test)
 {
     Test = test;
 }
Exemplo n.º 4
0
 public Test3(Test1 test1, Test test, Test2 test2)
 {
     this.Test1 = test1;
     this.Test  = test;
     this.Test2 = test2;
 }