Example #1
0
        public void TestResolvedInstanceHasBindingDescriptor()
        {
            IDIContext context = ContextHelper.CreateContext();
            IOrange    orange  = new Orange1();

            (orange as IDIClosedContext).Invalidate();
            context.s().BindInstance(orange);
            context.m().Bind <IPineapple>(() => new Pineapple());

            IPineapple pineApple = context.Resolve <IPineapple>();

            Assert.IsNotNull(pineApple);
            Assert.IsNotNull(pineApple.orange);
        }
Example #2
0
        public void TestNullNameResolve()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.m().Bind <IPineapple> (() => new Pineapple());
            context.m().Bind <IOrange> (() => new Orange1());

            IPineapple appleInstance = context.Resolve <IPineapple> (null, null);

            Assert.IsNotNull(appleInstance);

            appleInstance = context.Resolve <IPineapple> ("");
            Assert.IsNotNull(appleInstance);
        }
Example #3
0
        public void TestSTNotSubjective()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.m().Bind <IOrange> (() => new Orange1());
            context.s().Bind <IPineapple> (() => new Pineapple());
            IDIContext childContext = context.Reproduce();

            childContext.m().Bind <IOrange> (() => new Orange2());

            IPineapple apple2 = childContext.Resolve <IPineapple> ();
            IPineapple apple1 = context.Resolve <IPineapple> ();

            Assert.AreSame(apple1, apple2);
            Assert.IsInstanceOf(typeof(Orange1), apple1.orange);
            Assert.IsInstanceOf(typeof(Orange1), apple2.orange);
        }