예제 #1
0
        public static IUnityContainer BootstrapContainer()
        {
            var container = new UnityContainer();
            var installers = new InstallersProvider(new Assembly[] { typeof(ContainerBootstrapper).Assembly }).GetInstallers();

            var containerConfigurator = new ContainerConfigurator(container, installers);
            containerConfigurator.ConfigureContainer();

            return container;
        }
        public void CanConfigureContainer()
        {
            using (var container = new UnityContainer())
            {
                var containerConfigurator = new ContainerConfigurator(container, new IContainerInstaller[] { new TestContainerInstaller() });
                containerConfigurator.ConfigureContainer();

                var resolvedMock = container.Resolve<IMock>();
                Assert.IsTrue(container.Registrations.FirstOrDefault(x => x.MappedToType == typeof(ConcreteMock)) != null, "Concreate mock should be registered");
                Assert.IsNotNull(resolvedMock, "Mock shouldn't be null");
            }
        }