Ejemplo n.º 1
0
        public void Transient_Singleton_Singleton_RootScope()
        {
            // Arrange
            ContainerBuilder containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType <FirstLayer>().As <IFirstLayer>().InstancePerDependency();
            containerBuilder.RegisterType <SecondLayer>().As <ISecondLayer>().SingleInstance();
            containerBuilder.RegisterType <SecondLayerA>().As <ISecondLayerA>().SingleInstance();
            containerBuilder.RegisterType <ThirdLayerA>().As <IThirdLayerA>().SingleInstance();
            containerBuilder.RegisterType <ThirdLayerB>().As <IThirdLayerB>().SingleInstance();
            IContainer container = containerBuilder.Build();
            // Act
            IThirdLayerA thirdLayerA  = container.Resolve <IThirdLayerA>();
            IThirdLayerB thirdLayerB  = container.Resolve <IThirdLayerB>();
            IThirdLayerB thirdLayerB2 = container.Resolve <IThirdLayerB>();

            // Assert
            thirdLayerA.AllInstanceNames.Should().NotEqual(thirdLayerB.AllInstanceNames);
            thirdLayerB.AllInstanceNames.Should().Equal(thirdLayerB2.AllInstanceNames);
        }
Ejemplo n.º 2
0
 public FourthLayerB(IThirdLayer thirdLayer, IThirdLayerA thirdLayerA, IThirdLayerB thirdLayerB)
 {
     ThirdLayer  = thirdLayer;
     ThirdLayerA = thirdLayerA;
     ThirdLayerB = thirdLayerB;
 }