Ejemplo n.º 1
0
        public void RegisterType_TwoDifferentImplementationsTwoDifferentInterfaces_TypesAreRegisteredAndResolved()
        {
            //Arrange
            IContainer container = new Container();
            Helper1    help1     = new Helper1();
            Helper2    help2     = new Helper2();

            //Act
            container.Register <IHelper1, Helper1>();
            container.Register <IHelper2, Helper2>();
            var actualType1 = container.Resolve <IHelper1>();
            var actualType2 = container.Resolve <IHelper2>();

            //Assert
            Assert.IsType(help1.GetType(), actualType1);
            Assert.IsType(help2.GetType(), actualType2);
        }
Ejemplo n.º 2
0
        public void RegisterType_OneInterfaceTwoDifferentImplementations_TypesAreRegisteredAndResolvedByType()
        {
            //Arrange
            Container container = new Container();
            IHelper1  help1     = new Helper1();
            IHelper1  help2     = new Helper2();

            //Act
            container.Register <IHelper1, Helper1>();
            container.Register <IHelper1, Helper2>();
            List <object> actualTypes = container.ResolveAll(typeof(IHelper1)).ToList();

            //Assert
            Assert.NotNull(actualTypes);
            Assert.Equal(help1.GetType().FullName, actualTypes[0].GetType().FullName);
            Assert.Equal(help2.GetType().FullName, actualTypes[1].GetType().FullName);
        }