public void ModuleManagerRunCalled() { // Have to use a non-mocked container because of IsRegistered<> extension method, Registrations property,and ContainerRegistration var container = new UnityContainer(); var mockedModuleInitializer = new Mock<IModuleInitializer>(); var mockedModuleManager = new Mock<IModuleManager>(); var regionAdapterMappings = new RegionAdapterMappings(); var serviceLocatorAdapter = new UnityServiceLocatorAdapter(container); var regionBehaviorFactory = new RegionBehaviorFactory(serviceLocatorAdapter); container.RegisterInstance<IServiceLocator>(serviceLocatorAdapter); container.RegisterInstance<UnityBootstrapperExtension>(new UnityBootstrapperExtension()); container.RegisterInstance<IModuleCatalog>(new ModuleCatalog()); container.RegisterInstance<IModuleInitializer>(mockedModuleInitializer.Object); container.RegisterInstance<IModuleManager>(mockedModuleManager.Object); container.RegisterInstance<RegionAdapterMappings>(regionAdapterMappings); container.RegisterInstance<SelectorRegionAdapter>(new SelectorRegionAdapter(regionBehaviorFactory)); container.RegisterInstance<ItemsControlRegionAdapter>(new ItemsControlRegionAdapter(regionBehaviorFactory)); container.RegisterInstance<ContentControlRegionAdapter>(new ContentControlRegionAdapter(regionBehaviorFactory)); var bootstrapper = new MockedContainerBootstrapper(container); bootstrapper.Run(); mockedModuleManager.Verify(mm => mm.Run(), Times.Once()); }
public void RunRegistersInstanceOfILoggerFacade() { var mockedContainer = new Mock <IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.RegisterInstance(typeof(ILoggerFacade), null, bootstrapper.BaseLogger, It.IsAny <IInstanceLifetimeManager>()), Times.Once()); }
public void RunRegistersInstanceOfIModuleCatalog() { var mockedContainer = new Mock <IContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.UseInstance(typeof(IModuleCatalog), It.IsAny <object>(), IfAlreadyRegistered.Replace, It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <object>())); }
public void RunRegistersTypeForIRegionViewRegistry() { var mockedContainer = new Mock <IContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.Register(It.IsAny <Factory>(), typeof(IRegionViewRegistry), null, It.IsAny <IfAlreadyRegistered?>(), It.IsAny <bool>()), Times.Once()); }
public void RunRegistersTypeForRegionAdapterMappings() { var mockedContainer = new Mock <IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.RegisterType(typeof(RegionAdapterMappings), It.IsAny <Type>(), null, It.IsAny <LifetimeManager>()), Times.Once()); }
public void RunRegistersInstanceOfIModuleCatalog() { var mockedContainer = new Mock <IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.RegisterInstance(typeof(IModuleCatalog), null, It.IsAny <object>(), It.IsAny <LifetimeManager>()), Times.Once()); }
public void RunRegistersTypeForIEventAggregator() { var mockedContainer = new Mock <IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.RegisterType(typeof(IEventAggregator), It.IsAny <Type>(), null, It.IsAny <ITypeLifetimeManager>()), Times.Once()); }
public void RunRegistersTypeForIServiceLocator() { var mockedContainer = new Mock <IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.RegisterType(typeof(IServiceLocator), typeof(UnityServiceLocatorAdapter), null, It.IsAny <LifetimeManager>()), Times.Once()); }
public void RunRegistersTypeForIEventAggregator() { var mockedContainer = new Mock <IIocContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.Register(It.IsAny <Func <IDependencyResolver, IEventAggregator> >()), Times.Once()); }
public void RunRegistersTypeForIModuleInitializer() { var mockedContainer = new Mock <IWindsorContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(container => container.Register(Component.For(typeof(IModuleInitializer)) .Instance(typeof(object)) .LifeStyle.Singleton), Times.Once()); }
public void RunFalseShouldNotRegisterDefaultServicesAndTypes() { var mockedContainer = new Mock <IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(false); mockedContainer.Verify(c => c.RegisterType(typeof(IEventAggregator), It.IsAny <Type>(), null, It.IsAny <ITypeLifetimeManager>()), Times.Never()); mockedContainer.Verify(c => c.RegisterType(typeof(IRegionManager), It.IsAny <Type>(), null, It.IsAny <ITypeLifetimeManager>()), Times.Never()); mockedContainer.Verify(c => c.RegisterType(typeof(RegionAdapterMappings), It.IsAny <Type>(), null, It.IsAny <ITypeLifetimeManager>()), Times.Never()); mockedContainer.Verify(c => c.RegisterType(typeof(IModuleInitializer), It.IsAny <Type>(), null, It.IsAny <ITypeLifetimeManager>()), Times.Never()); }
public void RunRegistersTypeForIServiceLocator() { var mockedContainer = new Mock <IWindsorContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(container => container.Register(Component.For(typeof(IServiceLocator)) .Instance(typeof(CastleWindsorServiceLocatorAdapter)) .LifeStyle.Singleton), Times.Once()); //mockedContainer.Verify(c => c.RegisterType(typeof(IServiceLocator), typeof(CastleWindsorServiceLocatorAdapter), null, It.IsAny<ITypeLifetimeManager>()), Times.Once()); }
public void RunRegistersInstanceOfIModuleCatalog() { var mockedContainer = new Mock <IWindsorContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(container => container.Register(Component.For(typeof(IModuleCatalog)) .Instance(It.IsAny <object>()) .LifeStyle.Singleton), Times.Once()); //mockedContainer.Verify(c => c.RegisterInstance(typeof(IModuleCatalog), null, It.IsAny<object>(), It.IsAny<IInstanceLifetimeManager>()), Times.Once()); }
public void RunRegistersTypeForIEventAggregator() { var mockedContainer = new Mock <IWindsorContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(container => container.Register(Component.For(typeof(IEventAggregator)) .Instance(typeof(object)) .LifeStyle.Transient), Times.Once()); //mockedContainer.Verify(c => c.RegisterType(typeof(IEventAggregator), It.IsAny<Type>(), null, It.IsAny<ITypeLifetimeManager>()), Times.Once()); }
public void RunFalseShouldNotRegisterDefaultServicesAndTypes() { var mockedContainer = new Mock <IIocContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(false); mockedContainer.Verify(c => c.Register(It.IsAny <Func <IDependencyResolver, IEventAggregator> >()), Times.Never()); mockedContainer.Verify(c => c.Register(It.IsAny <Func <IDependencyResolver, IRegionManager> >()), Times.Never()); mockedContainer.Verify(c => c.Register(It.IsAny <Func <IDependencyResolver, RegionAdapterMappings> >()), Times.Never()); mockedContainer.Verify(c => c.Register(It.IsAny <Func <IDependencyResolver, IServiceLocator> >()), Times.Never()); mockedContainer.Verify(c => c.Register(It.IsAny <Func <IDependencyResolver, IModuleInitializer> >()), Times.Never()); }
public void RunRegistersInstanceOfILoggerFacade() { var mockedContainer = new Mock <IWindsorContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); //Container.Register(Component.For(typeof(ILoggerFacade)) // .Instance(Logger) // .LifeStyle.Singleton); mockedContainer.Verify(container => container.Register(Component.For(typeof(ILoggerFacade)) .Instance(bootstrapper.BaseLogger) .LifeStyle.Singleton), Times.Once()); //mockedContainer.Verify(c => c.RegisterInstance(typeof(ILoggerFacade), null, bootstrapper.BaseLogger, It.IsAny<IInstanceLifetimeManager>()), Times.Once()); }
public void ModuleManagerRunCalled() { // Have to use a non-mocked container because of IsRegistered<> extension method, Registrations property,and ContainerRegistration var container = new UnityContainer(); var mockedModuleInitializer = new Mock <IModuleInitializer>(); var mockedModuleManager = new Mock <IModuleManager>(); var regionAdapterMappings = new RegionAdapterMappings(); var serviceLocatorAdapter = new UnityServiceLocatorAdapter(container); var regionBehaviorFactory = new RegionBehaviorFactory(serviceLocatorAdapter); container.RegisterInstance <IServiceLocator>(serviceLocatorAdapter); container.RegisterInstance <UnityBootstrapperExtension>(new UnityBootstrapperExtension()); container.RegisterInstance <IModuleCatalog>(new ModuleCatalog()); container.RegisterInstance <IModuleInitializer>(mockedModuleInitializer.Object); container.RegisterInstance <IModuleManager>(mockedModuleManager.Object); container.RegisterInstance <RegionAdapterMappings>(regionAdapterMappings); container.RegisterSingleton(typeof(RegionAdapterMappings), typeof(RegionAdapterMappings)); container.RegisterSingleton(typeof(IRegionManager), typeof(RegionManager)); container.RegisterSingleton(typeof(IEventAggregator), typeof(EventAggregator)); container.RegisterSingleton(typeof(IRegionViewRegistry), typeof(RegionViewRegistry)); container.RegisterSingleton(typeof(IRegionBehaviorFactory), typeof(RegionBehaviorFactory)); container.RegisterSingleton(typeof(IRegionNavigationJournalEntry), typeof(RegionNavigationJournalEntry)); container.RegisterSingleton(typeof(IRegionNavigationJournal), typeof(RegionNavigationJournal)); container.RegisterSingleton(typeof(IRegionNavigationService), typeof(RegionNavigationService)); container.RegisterSingleton(typeof(IRegionNavigationContentLoader), typeof(Regions.UnityRegionNavigationContentLoader)); container.RegisterInstance <SelectorRegionAdapter>(new SelectorRegionAdapter(regionBehaviorFactory)); container.RegisterInstance <ItemsControlRegionAdapter>(new ItemsControlRegionAdapter(regionBehaviorFactory)); container.RegisterInstance <ContentControlRegionAdapter>(new ContentControlRegionAdapter(regionBehaviorFactory)); var bootstrapper = new MockedContainerBootstrapper(container); bootstrapper.Run(false); mockedModuleManager.Verify(mm => mm.Run(), Times.Once()); }
public void ModuleManagerRunCalled() { var mockedContainer = new Mock<IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var mockedModuleManager = new Mock<IModuleManager>(); mockedContainer.Setup(c => c.Resolve(typeof(IModuleManager), (string)null)).Returns( mockedModuleManager.Object); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedModuleManager.Verify(mm => mm.Run(), Times.Once()); }
public void RunFalseShouldNotRegisterDefaultServicesAndTypes() { var mockedContainer = new Mock<IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(false); mockedContainer.Verify(c => c.RegisterType(typeof(IEventAggregator), It.IsAny<Type>(), null, It.IsAny<LifetimeManager>()), Times.Never()); mockedContainer.Verify(c => c.RegisterType(typeof(IRegionManager), It.IsAny<Type>(), null, It.IsAny<LifetimeManager>()), Times.Never()); mockedContainer.Verify(c => c.RegisterType(typeof(RegionAdapterMappings), It.IsAny<Type>(), null, It.IsAny<LifetimeManager>()), Times.Never()); mockedContainer.Verify(c => c.RegisterType(typeof(IServiceLocator), It.IsAny<Type>(), null, It.IsAny<LifetimeManager>()), Times.Never()); mockedContainer.Verify(c => c.RegisterType(typeof(IModuleInitializer), It.IsAny<Type>(), null, It.IsAny<LifetimeManager>()), Times.Never()); }
public void RunRegistersTypeForIEventAggregator() { var mockedContainer = new Mock<IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.RegisterType(typeof(IEventAggregator), It.IsAny<Type>(), null, It.IsAny<LifetimeManager>()), Times.Once()); }
public void RunRegistersInstanceOfIModuleCatalog() { var mockedContainer = new Mock<IUnityContainer>(); SetupMockedContainerForVerificationTests(mockedContainer); var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); bootstrapper.Run(); mockedContainer.Verify(c => c.RegisterInstance(typeof(IModuleCatalog), null, It.IsAny<object>(), It.IsAny<LifetimeManager>()), Times.Once()); }