public void SetUpContainerAndBeginScope()
 {
     Container = new WindsorContainer();
     Container.ConfigureWiringForTestsCallBeforeAllOtherWiring();
     Container.Register(
         Component.For<SynchronousBus>(),
         Component.For<EventsReplayer>(),
         Component.For<IWindsorContainer>().Instance(Container));
     new MessageHandlersRegister().RegisterMessageHandlersForTestingFromAssemblyContaining<MessageHandlersTestBase>(Container);
     Container.ConfigureWiringForTestsCallAfterAllOtherWiring();
     _scope = Container.BeginScope();
 }
 public void SetUpContainerAndBeginScope()
 {
     Container = new WindsorContainer();
     Container.ConfigureWiringForTestsCallBeforeAllOtherWiring();
     Container.Register(
         Component.For <SynchronousBus>(),
         Component.For <EventsReplayer>(),
         Component.For <IWindsorContainer>().Instance(Container));
     new MessageHandlersRegister().RegisterMessageHandlersForTestingFromAssemblyContaining <MessageHandlersTestBase>(Container);
     Container.ConfigureWiringForTestsCallAfterAllOtherWiring();
     _scope = Container.BeginScope();
 }
        public void SetupContainer()
        {
            _container = new WindsorContainer();
            _container.ConfigureWiringForTestsCallBeforeAllOtherWiring();
            ApplicationBootstrapper.ConfigureContainer(_container);

            _container.Register(
                Component.For<IServiceBus>().ImplementedBy<SynchronousBus>()
                    .Named("TestReplacementServiceBus")
                    .LifestylePerWebRequest()
                    .IsDefault()
                );

            _container.ConfigureWiringForTestsCallAfterAllOtherWiring();
        }
        public void SetupContainer()
        {
            _container = new WindsorContainer();
            _container.ConfigureWiringForTestsCallBeforeAllOtherWiring();
            ApplicationBootstrapper.ConfigureContainer(_container);

            _container.Register(
                Component.For <IServiceBus>().ImplementedBy <SynchronousBus>()
                .Named("TestReplacementServiceBus")
                .LifestylePerWebRequest()
                .IsDefault()
                );

            _container.ConfigureWiringForTestsCallAfterAllOtherWiring();
        }
        public void SetupContainerAndScope()
        {
            Container = new WindsorContainer();
            Container.ConfigureWiringForTestsCallBeforeAllOtherWiring();
            Container.Install(
                FromAssembly.Containing<Domain.ContainerInstallers.AccountRepositoryInstaller>(),
                FromAssembly.Containing<Domain.Events.EventStore.ContainerInstallers.AccountManagementDomainEventStoreInstaller>(),
                FromAssembly.Containing<UI.QueryModels.ContainerInstallers.AccountManagementDocumentDbReaderInstaller>(),
                FromAssembly.Containing<UI.QueryModels.DocumentDB.Updaters.ContainerInstallers.AccountManagementQuerymodelsSessionInstaller>()
                );

            Container.Register(
                Component.For<IWindsorContainer>().Instance(Container),
                Component.For<IServiceBus>().ImplementedBy<SynchronousBus>()
                );

            Container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            _scope = Container.BeginScope();
        }
        public static WindsorContainer SetupContainerForTesting()
        {
            var container = new WindsorContainer();
            container.ConfigureWiringForTestsCallBeforeAllOtherWiring();

            container.Register(
                Component.For<MessageSpy, IHandleMessages<IMessage>>().Instance(new MessageSpy()),
                Component.For<IUtcTimeTimeSource, DummyTimeSource>().Instance(DummyTimeSource.Now).LifestyleSingleton(),
                Component.For<IServiceBus>().ImplementedBy<SynchronousBus>().LifestylePerWebRequest(),
                Component.For<IWindsorContainer>().Instance(container),
                Component.For<IConnectionStringProvider>().Instance(new ConnectionStringConfigurationParameterProvider()).LifestyleSingleton()
                );

            container.Install(
                FromAssembly.Containing<Domain.ContainerInstallers.AccountRepositoryInstaller>(),
                FromAssembly.Containing<Domain.Events.EventStore.ContainerInstallers.AccountManagementDomainEventStoreInstaller>()
                );          

            container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            return container;
        }
        public static WindsorContainer SetupContainerForTesting()
        {
            var container = new WindsorContainer();
            container.ConfigureWiringForTestsCallBeforeAllOtherWiring();
            container.Install(
                FromAssembly.Containing<Domain.ContainerInstallers.AccountRepositoryInstaller>(),
                FromAssembly.Containing<Domain.Events.EventStore.ContainerInstallers.AccountManagementDomainEventStoreInstaller>()
                );

            container.Register(
                Component.For<MessageSpy, IHandleMessages<IMessage>>().Instance(new MessageSpy())
                );

            container.Register(
                Component.For<IServiceBus>().ImplementedBy<SynchronousBus>().LifestylePerWebRequest(),
                Component.For<IWindsorContainer>().Instance(container)
                );

            container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            return container;
        }
Beispiel #8
0
        public void SetupTask()
        {
            _container = new WindsorContainer();

            _container.ConfigureWiringForTestsCallBeforeAllOtherWiring();

            _messageReceiver = new MessageReceiver();
            _timeSource      = DummyTimeSource.FromLocalTime(DateTime.Parse("2015-01-01 10:00"));

            _container.Register(
                Component.For <DummyTimeSource>().Instance(_timeSource),
                Component.For <IServiceBus>().ImplementedBy <TestingOnlyServiceBus>().LifestyleScoped(),
                Component.For <IWindsorContainer>().Instance(_container),
                Component.For <IHandleMessages <ScheduledMessage> >().Instance(_messageReceiver)
                );

            _container.ConfigureWiringForTestsCallAfterAllOtherWiring();

            _scope = _container.BeginScope();

            _bus = _container.Resolve <IServiceBus>();
        }
        public void SetupContainerAndScope()
        {
            Container = new WindsorContainer();
            Container.ConfigureWiringForTestsCallBeforeAllOtherWiring();

            Container.Register(
                Component.For<IUtcTimeTimeSource, DummyTimeSource>().Instance(DummyTimeSource.Now).LifestyleSingleton(),
                Component.For<IWindsorContainer>().Instance(Container),
                Component.For<IServiceBus>().ImplementedBy<SynchronousBus>(),
                Component.For<IConnectionStringProvider>().Instance(new ConnectionStringConfigurationParameterProvider()).LifestyleSingleton()
                );

            Container.Install(
                FromAssembly.Containing<Domain.ContainerInstallers.AccountRepositoryInstaller>(),
                FromAssembly.Containing<Domain.Events.EventStore.ContainerInstallers.AccountManagementDomainEventStoreInstaller>(),
                FromAssembly.Containing<UI.QueryModels.ContainerInstallers.AccountManagementDocumentDbReaderInstaller>(),
                FromAssembly.Containing<UI.QueryModels.DocumentDB.Updaters.ContainerInstallers.AccountManagementQuerymodelsSessionInstaller>()
                );            

            Container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            _scope = Container.BeginScope();
        }
        public static WindsorContainer SetupContainerForTesting()
        {
            var container = new WindsorContainer();

            container.ConfigureWiringForTestsCallBeforeAllOtherWiring();

            container.Register(
                Component.For <MessageSpy, IHandleMessages <IMessage> >().Instance(new MessageSpy()),
                Component.For <IUtcTimeTimeSource, DummyTimeSource>().Instance(DummyTimeSource.Now).LifestyleSingleton(),
                Component.For <IServiceBus>().ImplementedBy <SynchronousBus>().LifestylePerWebRequest(),
                Component.For <IWindsorContainer>().Instance(container),
                Component.For <IConnectionStringProvider>().Instance(new ConnectionStringConfigurationParameterProvider()).LifestyleSingleton()
                );

            container.Install(
                FromAssembly.Containing <Domain.ContainerInstallers.AccountRepositoryInstaller>(),
                FromAssembly.Containing <Domain.Events.EventStore.ContainerInstallers.AccountManagementDomainEventStoreInstaller>()
                );

            container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            return(container);
        }
Beispiel #11
0
        public void SetupContainerAndScope()
        {
            Container = new WindsorContainer();
            Container.ConfigureWiringForTestsCallBeforeAllOtherWiring();

            Container.Register(
                Component.For <IUtcTimeTimeSource, DummyTimeSource>().Instance(DummyTimeSource.Now).LifestyleSingleton(),
                Component.For <IWindsorContainer>().Instance(Container),
                Component.For <IServiceBus>().ImplementedBy <SynchronousBus>(),
                Component.For <IConnectionStringProvider>().Instance(new ConnectionStringConfigurationParameterProvider()).LifestyleSingleton()
                );

            Container.Install(
                FromAssembly.Containing <Domain.ContainerInstallers.AccountRepositoryInstaller>(),
                FromAssembly.Containing <Domain.Events.EventStore.ContainerInstallers.AccountManagementDomainEventStoreInstaller>(),
                FromAssembly.Containing <UI.QueryModels.ContainerInstallers.AccountManagementDocumentDbReaderInstaller>(),
                FromAssembly.Containing <UI.QueryModels.DocumentDB.Updaters.ContainerInstallers.AccountManagementQuerymodelsSessionInstaller>()
                );

            Container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            _scope = Container.BeginScope();
        }
        protected static WindsorContainer CreateContainerForEventStoreType(Func<IReadOnlyList<IEventMigration>> migrationsfactory, Type eventStoreType, string eventStoreConnectionString = null)
        {
            var container = new WindsorContainer();

            container.ConfigureWiringForTestsCallBeforeAllOtherWiring();

            container.Register(
                Component.For<IUtcTimeTimeSource, DummyTimeSource>()
                    .Instance(DummyTimeSource.Now)
                    .LifestyleSingleton(),
                Component.For<IServiceBus>()
                         .ImplementedBy<SynchronousBus>()
                         .LifestylePerWebRequest(),
                Component.For<IEnumerable<IEventMigration>>()
                         .UsingFactoryMethod(migrationsfactory)
                         .LifestylePerWebRequest(),
                Component.For<IEventStoreSession, IUnitOfWorkParticipant>()
                         .ImplementedBy<EventStoreSession>()
                         .LifestylePerWebRequest(),
                Component.For<IWindsorContainer>().Instance(container)
                );


            if (eventStoreType == typeof(SqlServerEventStore))
            {
                if(eventStoreConnectionString == null)
                {
                    var masterConnectionSTring = new ConnectionStringConfigurationParameterProvider().GetConnectionString("MasterDB");
                    var dbManager = new TemporaryLocalDbManager(masterConnectionSTring.ConnectionString, container);

                    eventStoreConnectionString = dbManager.CreateOrGetLocalDb($"{nameof(EventStreamMutatorTestsBase)}_EventStore");
                }

                container.Register(                    
                    Component.For<IEventStore>()
                             .ImplementedBy<SqlServerEventStore>()
                             .DependsOn(Dependency.OnValue<string>(eventStoreConnectionString))
                             .LifestyleScoped());

            }
            else if(eventStoreType == typeof(InMemoryEventStore))
            {
                container.Register(
                    Component.For<IEventStore>()
                             .UsingFactoryMethod(
                                 kernel =>
                                 {
                                     var store = kernel.Resolve<InMemoryEventStore>();
                                     store.TestingOnlyReplaceMigrations(migrationsfactory());
                                     return store;
                                 })
                             .LifestyleScoped(),
                    Component.For<InMemoryEventStore>()
                        .ImplementedBy<InMemoryEventStore>()
                        .LifestyleSingleton());
            }
            else
            {
                throw new Exception($"Unsupported type of event store {eventStoreType}");
            }            

            container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            return container;
        }
        protected static WindsorContainer CreateContainerForEventStoreType(Func <IReadOnlyList <IEventMigration> > migrationsfactory, Type eventStoreType, string eventStoreConnectionString = null)
        {
            var container = new WindsorContainer();

            container.ConfigureWiringForTestsCallBeforeAllOtherWiring();

            container.Register(
                Component.For <IUtcTimeTimeSource, DummyTimeSource>()
                .Instance(DummyTimeSource.Now)
                .LifestyleSingleton(),
                Component.For <IServiceBus>()
                .ImplementedBy <SynchronousBus>()
                .LifestylePerWebRequest(),
                Component.For <IEnumerable <IEventMigration> >()
                .UsingFactoryMethod(migrationsfactory)
                .LifestylePerWebRequest(),
                Component.For <IEventStoreSession, IUnitOfWorkParticipant>()
                .ImplementedBy <EventStoreSession>()
                .LifestylePerWebRequest(),
                Component.For <IWindsorContainer>().Instance(container)
                );


            if (eventStoreType == typeof(SqlServerEventStore))
            {
                if (eventStoreConnectionString == null)
                {
                    var masterConnectionSTring = new ConnectionStringConfigurationParameterProvider().GetConnectionString("MasterDB");
                    var dbManager = new TemporaryLocalDbManager(masterConnectionSTring.ConnectionString, container);

                    eventStoreConnectionString = dbManager.CreateOrGetLocalDb($"{nameof(EventStreamMutatorTestsBase)}_EventStore");
                }

                container.Register(
                    Component.For <IEventStore>()
                    .ImplementedBy <SqlServerEventStore>()
                    .DependsOn(Dependency.OnValue <string>(eventStoreConnectionString))
                    .LifestyleScoped());
            }
            else if (eventStoreType == typeof(InMemoryEventStore))
            {
                container.Register(
                    Component.For <IEventStore>()
                    .UsingFactoryMethod(
                        kernel =>
                {
                    var store = kernel.Resolve <InMemoryEventStore>();
                    store.TestingOnlyReplaceMigrations(migrationsfactory());
                    return(store);
                })
                    .LifestyleScoped(),
                    Component.For <InMemoryEventStore>()
                    .ImplementedBy <InMemoryEventStore>()
                    .LifestyleSingleton());
            }
            else
            {
                throw new Exception($"Unsupported type of event store {eventStoreType}");
            }

            container.ConfigureWiringForTestsCallAfterAllOtherWiring();
            return(container);
        }