Esempio n. 1
0
        public void ShouldInjectLazilyForDefaultInstanceRegistrations()
        {
            var sample = new TestCase1();

            locator
                .Register(Given<ITestInterface>.Then(sample))
                .Register(Given<TestClass>.Then<TestClass>());

            var instance = locator.GetInstance<TestClass>();

            Assert.AreSame(sample, instance.Invoke());
        }
Esempio n. 2
0
        public void ShouldInjectLazilyForConditionalInstanceRegistrations()
        {
            var sample1 = new TestCase1();
            var sample2 = new TestCase2();

            locator
                .Register(Given<ITestInterface>.When<int>(i => i == 1).Then(sample1))
                .Register(Given<ITestInterface>.When<int>(i => i == 2).Then(sample2))
                .Register(Given<TestClass>.Then<TestClass>());

            locator.AddContext(1);
            var instance = locator.GetInstance<TestClass>();
            Assert.AreSame(sample1, instance.Invoke());

            locator.Store.Get<IContextStore>().Clear();
            locator.AddContext(2);

            instance = locator.GetInstance<TestClass>();
            Assert.AreSame(sample2, instance.Invoke());
        }
Esempio n. 3
0
 public TestContainer(TestCase1 testCase)
 {
     this.testCase = testCase;
 }