public void RunConfiguresServiceLocatorProvider()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();

            Assert.IsTrue(ServiceLocator.Current is AutofacServiceLocatorAdapter);
        }
        public void RunShouldCallInitializeModules()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.InitializeModulesCalled);
        }
        public void ContainerDefaultsToNull()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            var container = bootstrapper.BaseContainer;

            Assert.IsNull(container);
        }
        public void RunShouldCallConfigureDefaultRegionBehaviors()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.ConfigureDefaultRegionBehaviorsCalled);
        }
        public void ConfigureContainerAddsLoggerFacadeToContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();

            var returnedCatalog = bootstrapper.BaseContainer.Resolve<ILoggerFacade>();
            Assert.IsNotNull(returnedCatalog);
        }
        public void RunAddsCompositionContainerToContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            var createdContainer = bootstrapper.CallCreateContainer();
            var returnedContainer = createdContainer.Resolve<IContainer>();
            Assert.IsNotNull(returnedContainer);
            Assert.IsTrue(returnedContainer.GetType().GetInterfaces().Contains(typeof(IContainer)));
        }
        public void ConfigureContainerAddsModuleCatalogToContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();

            var returnedCatalog = bootstrapper.BaseContainer.Resolve<IModuleCatalog>();
            Assert.IsNotNull(returnedCatalog);
            Assert.IsTrue(returnedCatalog is ModuleCatalog);
        }
        public void CreateContainerShouldInitializeContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            IContainer container = bootstrapper.CallCreateContainer();

            Assert.IsNotNull(container);
            Assert.IsInstanceOfType(container, typeof(IContainer));
        }
Example #9
0
        public void RunRegistersInstanceOfILoggerFacade()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var logger = bootstrapper.BaseContainer.Resolve <ILoggerFacade>();

            Assert.NotNull(logger);
            Assert.True(logger.GetType().IsClass);
            Assert.Contains(typeof(ILoggerFacade), logger.GetType().GetInterfaces());
        }
Example #10
0
        public void RunRegistersInstanceOfIModuleCatalog()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var moduleCatalog = bootstrapper.BaseContainer.Resolve <IModuleCatalog>();

            Assert.NotNull(moduleCatalog);
            Assert.True(moduleCatalog.GetType().IsClass);
            Assert.Contains(typeof(IModuleCatalog), moduleCatalog.GetType().GetInterfaces());
        }
Example #11
0
        public void RunRegistersTypeForIModuleInitializer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var moduleInitializer = bootstrapper.BaseContainer.Resolve <IModuleInitializer>();

            Assert.NotNull(moduleInitializer);
            Assert.True(moduleInitializer.GetType().IsClass);
            Assert.Contains(typeof(IModuleInitializer), moduleInitializer.GetType().GetInterfaces());
        }
Example #12
0
        public void RunRegistersTypeForIRegionBehaviorFactory()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var regionBehaviorFactory = bootstrapper.BaseContainer.Resolve <IRegionBehaviorFactory>();

            Assert.NotNull(regionBehaviorFactory);
            Assert.True(regionBehaviorFactory.GetType().IsClass);
            Assert.Contains(typeof(IRegionBehaviorFactory), regionBehaviorFactory.GetType().GetInterfaces());
        }
Example #13
0
        public void RunShouldNotLogAboutInitializingTheShellIfShellIsNotCreated()
        {
            const string expectedMessageText = "Initializing shell";
            var          bootstrapper        = new DefaultAutofacBootstrapper {
                ShellObject = null
            };

            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsFalse(messages.Contains(expectedMessageText));
        }
Example #14
0
        public void RunRegistersTypeForIEventAggregator()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var eventAggregator = bootstrapper.BaseContainer.Resolve <IEventAggregator>();

            Assert.NotNull(eventAggregator);
            Assert.True(eventAggregator.GetType().IsClass);
            Assert.Contains(typeof(IEventAggregator), eventAggregator.GetType().GetInterfaces());
        }
Example #15
0
        public void RunRegistersTypeForIRegionManager()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var regionManager = bootstrapper.BaseContainer.Resolve <IRegionManager>();

            Assert.IsNotNull(regionManager);
            Assert.IsTrue(regionManager.GetType().IsClass);
            Assert.IsTrue(regionManager.GetType().GetInterfaces().Contains(typeof(IRegionManager)));
        }
        public void ConfigureContainerAddsRegionNavigationJournalToContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();

            var actual1 = bootstrapper.BaseContainer.Resolve<IRegionNavigationJournal>();
            var actual2 = bootstrapper.BaseContainer.Resolve<IRegionNavigationJournal>();

            Assert.IsNotNull(actual1);
            Assert.IsNotNull(actual2);
            Assert.AreNotSame(actual1, actual2);
        }
Example #17
0
        public void ConfigureContainerAddsRegionNavigationJournalToContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var actual1 = bootstrapper.BaseContainer.Resolve <IRegionNavigationJournal>();
            var actual2 = bootstrapper.BaseContainer.Resolve <IRegionNavigationJournal>();

            Assert.NotNull(actual1);
            Assert.NotNull(actual2);
            Assert.NotSame(actual1, actual2);
        }
Example #18
0
        public void ConfigureContainerAddsNavigationTargetHandlerToContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var actual1 = bootstrapper.BaseContainer.Resolve <IRegionNavigationContentLoader>();
            var actual2 = bootstrapper.BaseContainer.Resolve <IRegionNavigationContentLoader>();

            Assert.NotNull(actual1);
            Assert.NotNull(actual2);
            Assert.Same(actual1, actual2);
        }
Example #19
0
        public void RunRegistersTypeForIServiceLocator()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var serviceLocator = bootstrapper.BaseContainer.Resolve <IServiceLocator>();

            Assert.NotNull(serviceLocator);
            Assert.True(serviceLocator.GetType().IsClass);
            Assert.Equal(typeof(AutofacServiceLocatorAdapter), serviceLocator.GetType());
            Assert.Contains(typeof(IServiceLocator), serviceLocator.GetType().GetInterfaces());
        }
        public void RunShouldInitializeContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            var container = bootstrapper.BaseContainer;

            Assert.IsNull(container);

            bootstrapper.Run();

            container = bootstrapper.BaseContainer;

            Assert.IsNotNull(container);
            Assert.IsInstanceOfType(container, typeof(IContainer));
        }
Example #21
0
        public void RunShouldInitializeContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            var container    = bootstrapper.BaseContainer;

            Assert.IsNull(container);

            bootstrapper.Run();

            container = bootstrapper.BaseContainer;

            Assert.IsNotNull(container);
            Assert.IsInstanceOfType(container, typeof(IContainer));
        }
Example #22
0
        public void RunShouldInitializeContainer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            var container    = bootstrapper.BaseContainer;

            Assert.Null(container);

            bootstrapper.Run();

            container = bootstrapper.BaseContainer;

            Assert.NotNull(container);
            Assert.IsAssignableFrom <IContainer>(container);
        }
Example #23
0
        public void RunShouldCallTheMethodsInOrder()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            Assert.Equal("CreateLogger", bootstrapper.MethodCalls[0]);
            Assert.Equal("CreateModuleCatalog", bootstrapper.MethodCalls[1]);
            Assert.Equal("ConfigureModuleCatalog", bootstrapper.MethodCalls[2]);
            Assert.Equal("CreateContainerBuilder", bootstrapper.MethodCalls[3]);
            Assert.Equal("ConfigureContainerBuilder", bootstrapper.MethodCalls[4]);
            Assert.Equal("CreateContainer", bootstrapper.MethodCalls[5]);
            Assert.Equal("ConfigureServiceLocator", bootstrapper.MethodCalls[6]);
            Assert.Equal("CreateContainerBuilder", bootstrapper.MethodCalls[7]); // update container
            Assert.Equal("ConfigureRegionAdapterMappings", bootstrapper.MethodCalls[8]);
            Assert.Equal("ConfigureDefaultRegionBehaviors", bootstrapper.MethodCalls[9]);
            Assert.Equal("RegisterFrameworkExceptionTypes", bootstrapper.MethodCalls[10]);
            Assert.Equal("CreateShell", bootstrapper.MethodCalls[11]);
            Assert.Equal("InitializeShell", bootstrapper.MethodCalls[12]);
            Assert.Equal("InitializeModules", bootstrapper.MethodCalls[13]);
        }
        public void RunRegistersTypeForIServiceLocator()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var serviceLocator = bootstrapper.BaseContainer.Resolve<IServiceLocator>();
            Assert.IsNotNull(serviceLocator);
            Assert.IsTrue(serviceLocator.GetType().IsClass);
            Assert.AreEqual(typeof(AutofacServiceLocatorAdapter), serviceLocator.GetType());
            Assert.IsTrue(serviceLocator.GetType().GetInterfaces().Contains(typeof(IServiceLocator)));
        }
        public void RunShouldLogAboutModuleCatalogCreation()
        {
            const string expectedMessageText = "Creating module catalog.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunRegistersTypeForIModuleInitializer()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var moduleInitializer = bootstrapper.BaseContainer.Resolve<IModuleInitializer>();
            Assert.IsNotNull(moduleInitializer);
            Assert.IsTrue(moduleInitializer.GetType().IsClass);
            Assert.IsTrue(moduleInitializer.GetType().GetInterfaces().Contains(typeof(IModuleInitializer)));
        }
 public void RunShouldNotFailIfReturnedNullShell()
 {
     var bootstrapper = new DefaultAutofacBootstrapper { ShellObject = null };
     bootstrapper.Run();
 }
Example #28
0
        public void CanRunBootstrapper()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();
        }
        public void RunShouldAssignRegionManagerToReturnedShell()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            Assert.IsNotNull(RegionManager.GetRegionManager(bootstrapper.BaseShell));
        }
        public void RunShouldLogAboutRegisteringFrameworkExceptionTypes()
        {
            const string expectedMessageText = "Registering Framework Exception Types.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunShouldLogLoggerCreationSuccess()
        {
            const string expectedMessageText = "Logger was created successfully.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunShouldLogAboutConfiguringContainerBuilder()
        {
            const string expectedMessageText = "Configuring the Autofac container builder.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunShouldLogAboutRunCompleting()
        {
            const string expectedMessageText = "Bootstrapper sequence completed.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunShouldLogAboutInitializingModules()
        {
            const string expectedMessageText = "Initializing modules.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunShouldNotLogAboutInitializingTheShellIfShellIsNotCreated()
        {
            const string expectedMessageText = "Initializing shell";
            var bootstrapper = new DefaultAutofacBootstrapper { ShellObject = null };

            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsFalse(messages.Contains(expectedMessageText));
        }
        public void RunShouldLogAboutCreatingTheShell()
        {
            const string expectedMessageText = "Creating the shell.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunRegistersInstanceOfIModuleCatalog()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var moduleCatalog = bootstrapper.BaseContainer.Resolve<IModuleCatalog>();
            Assert.IsNotNull(moduleCatalog);
            Assert.IsTrue(moduleCatalog.GetType().IsClass);
            Assert.IsTrue(moduleCatalog.GetType().GetInterfaces().Contains(typeof(IModuleCatalog)));
        }
        public void RunShouldCallConfigureRegionAdapterMappings()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.ConfigureRegionAdapterMappingsCalled);
        }
        public void RunRegistersTypeForIEventAggregator()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var eventAggregator = bootstrapper.BaseContainer.Resolve<IEventAggregator>();
            Assert.IsNotNull(eventAggregator);
            Assert.IsTrue(eventAggregator.GetType().IsClass);
            Assert.IsTrue(eventAggregator.GetType().GetInterfaces().Contains(typeof(IEventAggregator)));
        }
        public void RunShouldCallTheMethodsInOrder()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();

            Assert.AreEqual("CreateLogger", bootstrapper.MethodCalls[0]);
            Assert.AreEqual("CreateModuleCatalog", bootstrapper.MethodCalls[1]);
            Assert.AreEqual("ConfigureModuleCatalog", bootstrapper.MethodCalls[2]);
            Assert.AreEqual("CreateContainerBuilder", bootstrapper.MethodCalls[3]);
            Assert.AreEqual("ConfigureContainerBuilder", bootstrapper.MethodCalls[4]);
            Assert.AreEqual("CreateContainer", bootstrapper.MethodCalls[5]);
            Assert.AreEqual("ConfigureServiceLocator", bootstrapper.MethodCalls[6]);
            Assert.AreEqual("CreateContainerBuilder", bootstrapper.MethodCalls[7]); // update container
            Assert.AreEqual("ConfigureRegionAdapterMappings", bootstrapper.MethodCalls[8]);
            Assert.AreEqual("ConfigureDefaultRegionBehaviors", bootstrapper.MethodCalls[9]);
            Assert.AreEqual("RegisterFrameworkExceptionTypes", bootstrapper.MethodCalls[10]);
            Assert.AreEqual("CreateShell", bootstrapper.MethodCalls[11]);
            Assert.AreEqual("InitializeShell", bootstrapper.MethodCalls[12]);
            Assert.AreEqual("InitializeModules", bootstrapper.MethodCalls[13]);
        }
        public void RunRegistersTypeForIRegionBehaviorFactory()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var regionBehaviorFactory = bootstrapper.BaseContainer.Resolve<IRegionBehaviorFactory>();
            Assert.IsNotNull(regionBehaviorFactory);
            Assert.IsTrue(regionBehaviorFactory.GetType().IsClass);
            Assert.IsTrue(regionBehaviorFactory.GetType().GetInterfaces().Contains(typeof(IRegionBehaviorFactory)));
        }
        public void RunRegistersTypeForRegionAdapterMappings()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();

            bootstrapper.Run();

            var regionAdapterMappings = bootstrapper.BaseContainer.Resolve<RegionAdapterMappings>();
            Assert.IsNotNull(regionAdapterMappings);
            Assert.AreEqual(typeof(RegionAdapterMappings), regionAdapterMappings.GetType());
        }
        public void RunShouldLogAboutConfiguringRegionBehaviors()
        {
            const string expectedMessageText = "Configuring default region behaviors.";
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages.Contains(expectedMessageText));
        }
        public void RunShouldLogBootstrapperSteps()
        {
            var bootstrapper = new DefaultAutofacBootstrapper();
            bootstrapper.Run();
            var messages = bootstrapper.BaseLogger.Messages;

            Assert.IsTrue(messages[0].Contains("Logger was created successfully."));
            Assert.IsTrue(messages[1].Contains("Creating module catalog."));
            Assert.IsTrue(messages[2].Contains("Configuring module catalog."));
            Assert.IsTrue(messages[3].Contains("Creating Autofac container builder."));
            Assert.IsTrue(messages[4].Contains("Configuring the Autofac container builder."));
            Assert.IsTrue(messages[5].Contains("Creating Autofac container."));
            Assert.IsTrue(messages[6].Contains("Configuring ServiceLocator singleton."));
            Assert.IsTrue(messages[7].Contains("Configuring the ViewModelLocator to use Autofac."));
            Assert.IsTrue(messages[8].Contains("Configuring region adapters."));
            Assert.IsTrue(messages[9].Contains("Configuring default region behaviors."));
            Assert.IsTrue(messages[10].Contains("Registering Framework Exception Types."));
            Assert.IsTrue(messages[11].Contains("Creating the shell."));
            Assert.IsTrue(messages[12].Contains("Setting the RegionManager."));
            Assert.IsTrue(messages[13].Contains("Updating Regions."));
            Assert.IsTrue(messages[14].Contains("Initializing the shell."));
            Assert.IsTrue(messages[15].Contains("Initializing modules."));
            Assert.IsTrue(messages[16].Contains("Bootstrapper sequence completed."));
        }