예제 #1
0
        public void ShouldThrowNoContainerExceptionWhenRegisteringWithTargetAndImplementationInstanceBeforeInitializingTheContainer()
        {
            //Arrange
            var containerExtension = new UnityExtension(registrationHelper, options);

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

            //Assert
            Assert.AreEqual(NoContainerException.DefaultMessage, result.Message);
        }
예제 #2
0
        public void ShouldRegisterWithTargetAndImplementationType()
        {
            //Arrange
            var container          = new UnityContainer();
            var containerExtension = new UnityExtension(registrationHelper, options);

            containerExtension.InitializeContainer(container);

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

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(LoadedAssemblyProvider));
        }