Example #1
0
        public void Register_WhenInvokedWithGenereicTypeAndInstanceAndContainerIsNotInitialized_ShouldThrowException()
        {
            //Arrange
            var containerExtension = new SimpleInjectorExtension(registrationHelper, options);

            //Act
            var result = ExceptionAssert.Throws <NoContainerException>(() => containerExtension.Register <IBootstrapperContainerExtension>(containerExtension));

            //Assert
            Assert.AreEqual(NoContainerException.DefaultMessage, result.Message);
        }
Example #2
0
        public void Register_WhenInvokedWithGenericTargetAndImplementationType_ShouldRegisterType()
        {
            //Arrange
            var container          = new Container();
            var containerExtension = new SimpleInjectorExtension(registrationHelper, options);

            containerExtension.InitializeContainer(container);

            //Act
            containerExtension.Register <IBootstrapperAssemblyProvider, LoadedAssemblyProvider>();
            var result = container.GetInstance <IBootstrapperAssemblyProvider>();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(LoadedAssemblyProvider));
        }
Example #3
0
        public void Register_WhenInvokedWithGenericTypeAndInstance_ShouldRegisterInstance()
        {
            //Arrange
            var container          = new Container();
            var containerExtension = new SimpleInjectorExtension(registrationHelper, options);

            containerExtension.InitializeContainer(container);

            //Act
            containerExtension.Register <IBootstrapperContainerExtension>(containerExtension);
            var result = container.GetInstance <IBootstrapperContainerExtension>();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(SimpleInjectorExtension));
            Assert.AreSame(containerExtension, result);
        }