Ejemplo n.º 1
0
        public void Container_CreateChild_ShouldThrowIfChildCountReachedTheLimit()
        {
            Config.Value.ServiceContainer.MaxChildCount = 1;

            //
            // this.Container-re mar nem lesz alkalmazva a MaxChildCount
            //

            using (var container = new ServiceContainer())
            {
                Assert.DoesNotThrow(() => container.CreateChild());
                Assert.Throws <InvalidOperationException>(() => container.CreateChild());
            }
        }
Ejemplo n.º 2
0
        public void ComplexTestWithChildContainer()
        {
            IServiceReference[] references;

            using (IServiceContainer container = new ServiceContainer())
            {
                container
                .Service <IInterface_1, Implementation_1>(Lifetime.Transient)
                .Service <IInterface_2, Implementation_2>(Lifetime.Singleton);

                IServiceContainer child = container.CreateChild();
                child
                .Service <IInterface_3, Implementation_3>(Lifetime.Transient)
                .Service <IInterface_4, Implementation_4>(Lifetime.Scoped);

                references = Validate(child.CreateInjector());
            }

            Assert.That(references.All(reference => reference.RefCount == 0));
        }