示例#1
0
        public void DoesAllowCircularDependencyForSingletonPropertyInjection()
        {
            Container container = new Container();

            // Singleton binding...
            container.Bind <ISomeTypeFive>().To <SomeTypeFive>().AsSingleton();
            container.Bind <ISomeTypeSix>().To <SomeTypeSix>().AsSingleton();

            // Resolve five...
            ISomeTypeFive five = container.Resolve <ISomeTypeFive>();

            Assert.IsNotNull(five);
            Assert.IsNotNull(five.Six);
            Assert.AreEqual(five, five.Six.Five);

            container = null;
        }
示例#2
0
        public void DoesNotAllowPropertyInjectedCircularDependency()
        {
            Container container = new Container();

            // Transient binding...
            container.Bind <ISomeTypeFive>().To <SomeTypeFive>();
            container.Bind <ISomeTypeSix>().To <SomeTypeSix>();

            // Resolve three... should be injected, but not crash due to circular dependency
            ISomeTypeFive five = container.Resolve <ISomeTypeFive>();

            Assert.IsNotNull(five);
            Assert.IsNotNull(five.Six);
            Assert.IsNull(five.Six.Five);

            container = null;
        }