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 ResolvingScopedComponents_ReturnsSameInstanceWithinTheScope() { IWindsorContainer container = new WindsorContainer(); container.Register( Component.For<IRepository<Client>>().ImplementedBy<ClientRepository>().LifeStyle.Scoped()); // IRepository<Client> can only be resolved within a scope using (container.BeginScope()) { var instanceA = container.Resolve<IRepository<Client>>(); var instanceB = container.Resolve<IRepository<Client>>(); Assert.AreSame(instanceA, instanceB); } using (container.BeginScope()) { var instanceC = container.Resolve<IRepository<Client>>(); } container.Dispose(); }
static void Main(string[] args) { var container = new WindsorContainer(); container.Install(FromAssembly.Named("Expenses")); using(container.BeginScope()) { var iconsService = container.Resolve<BL.ExpenseIconService>(); var context = container.Resolve<BL.UnitOfWorkContext>(); foreach (var file in System.IO.Directory.GetFiles(@"..\..\Icons\", "*.png")) { iconsService.CreateNewFromFile(Path.GetFileNameWithoutExtension(file), "image/png", File.ReadAllBytes(file)); context.SaveChanges(); } } }
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(); }
/// <summary> /// Регистрация по нескольким интерфейсам, резолв скоупт-компонентов возвращает один и тот же объект по разным /// интерфейсам /// </summary> private static void Example7() { var container = new WindsorContainer(); var reg1 = Component.For <I1>().ImplementedBy <C1>().LifestyleTransient(); var reg2 = Component.For <I2>().Forward <I3>().ImplementedBy <C2>().LifestyleScoped(); container.Register(reg1); container.Register(reg2); var scope1 = container.BeginScope(); var transientComponent1 = container.Resolve <I1>(); var transientComponent2 = container.Resolve <I1>(); scope1.Dispose(); Console.WriteLine(ReferenceEquals(transientComponent1, transientComponent2)); Console.WriteLine(ReferenceEquals(transientComponent1.I2, transientComponent2.I3)); }
public static IWindsorContainer CreateContainerBuilder() { // create container with the runtime dependencies //var container = Bootstrapper.GetContainer(); var container = new WindsorContainer(); // Begin scope, as this method is called before every scenario // anything using LifestyleScoped will also be recreated before // each scenario. container.BeginScope(); container.Register( // scoped to ensure fresh dependencies on every scenario - can be changed // if you want your dependencies to exist for the entire test run // usually want scoped. Types.FromAssemblyInThisApplication().Where(t => t.IsDefined(typeof(BindingAttribute), false)).LifestyleScoped()); return(container); }
public static IWindsorContainer CreateContainerBuilder() { // create container with the runtime dependencies //var container = Bootstrapper.GetContainer(); // to load from an existing container var container = new WindsorContainer(); // new container // begin scope to allow the Binding files and context to get recreated // before every scenario to ensure fresh dependencies. // If Scoped is not selected the dependencies will be created only at the beginning // of the test run container.BeginScope(); container.Register(Types.FromAssemblyInThisApplication().Where(t => t.IsDefined(typeof(BindingAttribute), false)).LifestyleScoped()); container.Install(FromAssembly.Containing <ICalculator>()); container.Install(FromAssembly.This()); return(container); }
public void RetrieveAll() { //arrange var entity1 = CreateExampleEntity(); var entity2 = CreateExampleEntity(); var entity3 = CreateExampleEntity(); //act using (WindsorContainer.BeginScope()) { var repository = WindsorContainer.Resolve <IExampleEntityRepository>(); var actual = repository.RetrieveAll(); //assert Assert.That(actual, Has.Count.EqualTo(3)); Assert.That(actual, Has.Some.EqualTo(entity1).Using(EntityCrudObjectComparer)); Assert.That(actual, Has.Some.EqualTo(entity2).Using(EntityCrudObjectComparer)); Assert.That(actual, Has.Some.EqualTo(entity3).Using(EntityCrudObjectComparer)); } }
/// <summary> /// Регистрация по нескольким интерфейсам, резолв скоупт-компонентов возвращает один и тот же объект по разным /// интерфейсам /// </summary> private static void Example4() { var container = new WindsorContainer(); var reg = Component.For <IInterface1>().Forward <IInterface2>().ImplementedBy <MyClass>().LifestyleScoped(); container.Register(reg); container.BeginScope(); var component1 = container.Resolve <IInterface1>(); Console.WriteLine(component1.GetType()); var component2 = container.Resolve <IInterface2>(); Console.WriteLine(component2.GetType()); Console.WriteLine(nameof(component1) + " == " + nameof(component2) + " is " + ReferenceEquals(component1, component2)); }
private static void Test1(WindsorContainer container) { Console.WriteLine("=================================================="); for (var i = 0; i < 3; i++) { using (container.BeginScope()) { Console.WriteLine(); var singletonService = container.Resolve <IService1>(); Console.WriteLine($"Dependent scoped service2 has guidId = {singletonService.Service2.GuidId}"); var scopedService = container.Resolve <IService2>(); Console.WriteLine( $"Resolved by container directly scoped service has guidId = {scopedService.GuidId}"); } } Console.WriteLine("==================================================\n"); }
public void RetrieveAllForTrue() { //arrange CreateExampleEntity(testBool: false); var entityWithTrue1 = CreateExampleEntity(); CreateExampleEntity(testBool: false); var entityWithTrue2 = CreateExampleEntity(); //act using (WindsorContainer.BeginScope()) { var repository = WindsorContainer.Resolve <IExampleEntityRepository>(); var actual = repository.RetrieveAllForTrue(); //assert Assert.That(actual, Has.Count.EqualTo(2)); Assert.That(actual, Has.Some.EqualTo(entityWithTrue1).Using(EntityCrudObjectComparer)); Assert.That(actual, Has.Some.EqualTo(entityWithTrue2).Using(EntityCrudObjectComparer)); } }
public void Delete() { //arrange var entity = CreateExampleEntity(); //act using (WindsorContainer.BeginScope()) { var repository = WindsorContainer.Resolve <IExampleEntityRepository>(); repository.Delete(entity); } //assert using (WindsorContainer.BeginScope()) { var repository = WindsorContainer.Resolve <IExampleEntityRepository>(); var entitiesFromDb = repository.RetrieveAll(); Assert.That(entitiesFromDb, Has.Count.EqualTo(0)); } }
public void UsingOnDistroyForScopedComponent_OnDestroyIsCalledScopeIsDisposed() { IWindsorContainer container = new WindsorContainer(); bool wasCalled = false; container.Register( Component.For<IRepository<Client>>() .ImplementedBy<ClientRepository>() .LifeStyle.Scoped() .OnDestroy(component => wasCalled = true)); using(container.BeginScope()) { // ClientRepository also implements IDisposable, // Windsor will call Dispose when the component is released var repository = container.Resolve<IRepository<Client>>(); } Assert.IsTrue(wasCalled); }
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 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 void Setup() { _container = new WindsorContainer(); RepositoryInstaller.InstallForTest(_container); _scope = _container.BeginScope(); }
public IDisposable BeginScope() { return(container.BeginScope()); }
public CastleWindsorScope(WindsorContainer container) { _container = container; _disposable = container.BeginScope(); }
private static void Main1(string[] args) { var container = new WindsorContainer(); container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel)); container.Register(Component.For <ConsoleLoggerInterceptor>().LifeStyle.Singleton.Named("consoleLogger")); container.Register( Component.For <IUsersContainer>() .ImplementedBy <InDbUsersContainer>() .LifestyleSingleton()); container.Register( Component.For <IOrdersContainer>() .ImplementedBy <InDbOrdersContainer>() .LifestyleSingleton()); container.Register( Component.For <IServiceInfoContainer>() .ImplementedBy <InDbServicesContainer>() .LifestyleSingleton()); container.Register( Component.For <IRolesContainer>() .ImplementedBy <InDbRolesContainer>() .LifestyleSingleton()); container.BeginScope(); var ordersContainer = container.Resolve <IOrdersContainer>(); var usersContainer = container.Resolve <IUsersContainer>(); var servicesContainer = container.Resolve <IServiceInfoContainer>(); var rolesContainer = container.Resolve <IRolesContainer>(); container.Register( Component.For <IUsersOperations>() .ImplementedBy <UserOperations>() .Interceptors(InterceptorReference.ForKey("consoleLogger")).Anywhere .LifestyleSingleton()); container.Register( Component.For <IServicesOperations>() .ImplementedBy <ServiceOperations>() .Interceptors(InterceptorReference.ForKey("consoleLogger")).Anywhere .LifestyleSingleton()); var userOperations = container.Resolve <IUsersOperations>(); var servicesOperations = container.Resolve <IServicesOperations>(); var mainMenu = new Menu(); var clientMenu = new Menu(); var managerMenu = new Menu(); var adminMenu = new Menu(); mainMenu.AddCommand(new EnterCommand("Вход", usersContainer, new[] { adminMenu, managerMenu, clientMenu })); mainMenu.AddCommand(new RegistrationCommand("Регистрация", usersContainer, rolesContainer, mainMenu)); clientMenu.AddCommand(new OrderServiceCommand("Заказать услугу", servicesContainer, userOperations, clientMenu)); clientMenu.AddCommand(new CancelOrderCommand("Отменить заказ", userOperations, ordersContainer, clientMenu)); clientMenu.AddCommand(new PayServiceCommand("Оплатить услугу", userOperations, ordersContainer, clientMenu)); clientMenu.AddCommand(new ExitCommand("Выход", mainMenu)); managerMenu.AddCommand(new ViewAllServicesCommand("Посмотреть все услуги", servicesContainer, managerMenu)); managerMenu.AddCommand(new ViewAllPaidServicesCommand("Посмотреть оплаченные услуги", ordersContainer, managerMenu)); managerMenu.AddCommand(new ChangeServiceCommand("Изменить услугу", servicesOperations, servicesContainer, managerMenu)); managerMenu.AddCommand(new ViewStatisticPerClientCommand("Посмотреть статистику по клиентам", ordersContainer, usersContainer, managerMenu)); managerMenu.AddCommand(new ViewAttendanceStatiscticsCommand("Статистика заказов", ordersContainer, managerMenu)); managerMenu.AddCommand(new ExitCommand("Выход", mainMenu)); adminMenu.AddCommand(new ViewAllServicesCommand("Посмотреть все услуги", servicesContainer, adminMenu)); adminMenu.AddCommand(new ViewAllPaidServicesCommand("Посмотреть оплаченные услуги", ordersContainer, adminMenu)); adminMenu.AddCommand(new ViewAllUnpaidServicesCommand("Посмотреть все неоплаченные услуги", ordersContainer, adminMenu)); adminMenu.AddCommand(new ViewAllUsersCommand("Посмотреть всех пользователей", usersContainer, adminMenu)); adminMenu.AddCommand(new ExitCommand("Выход", mainMenu)); mainMenu.Print(); mainMenu.SetCommand(mainMenu.ReadCommand()); mainMenu.Run(); }
public static IDisposable BeginScope() => container.BeginScope();
protected void ReplaceContainerScope() { _scope.Dispose(); _scope = Container.BeginScope(); }
private static void RunScenarioWithEventStoreType (MigrationScenario scenario, Type eventStoreType, WindsorContainer container, IList<IEventMigration> migrations, int indexOfScenarioInBatch) { var startingMigrations = migrations.ToList(); migrations.Clear(); var timeSource = container.Resolve<DummyTimeSource>(); IReadOnlyList<IAggregateRootEvent> eventsInStoreAtStart; using(container.BeginScope()) //Why is this needed? It fails without it but I do not understand why... { var eventStore = container.Resolve<IEventStore>(); eventsInStoreAtStart = eventStore.ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize(); } Console.WriteLine($"\n########Running Scenario {indexOfScenarioInBatch}"); var original = TestAggregate.FromEvents(DummyTimeSource.Now, scenario.AggregateId, scenario.OriginalHistory).History.ToList(); Console.WriteLine($"Original History: "); original.ForEach(e => Console.WriteLine($" {e}")); Console.WriteLine(); var initialAggregate = TestAggregate.FromEvents(timeSource, scenario.AggregateId, scenario.OriginalHistory); var expected = TestAggregate.FromEvents(timeSource, scenario.AggregateId, scenario.ExpectedHistory).History.ToList(); var expectedCompleteEventstoreStream = eventsInStoreAtStart.Concat(expected).ToList(); Console.WriteLine($"Expected History: "); expected.ForEach(e => Console.WriteLine($" {e}")); Console.WriteLine(); var initialAggregate2 = TestAggregate.FromEvents(timeSource, scenario.AggregateId, scenario.OriginalHistory); timeSource.UtcNow += 1.Hours();//Bump clock to ensure that times will be be wrong unless the time from the original events are used.. Console.WriteLine("Doing pure in memory "); IReadOnlyList<IAggregateRootEvent> otherHistory = SingleAggregateInstanceEventStreamMutator.MutateCompleteAggregateHistory( scenario.Migrations, initialAggregate2.History.Cast<AggregateRootEvent>().ToList()); AssertStreamsAreIdentical(expected, otherHistory, $"Direct call to SingleAggregateInstanceEventStreamMutator.MutateCompleteAggregateHistory"); container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStoreSession>().Save(initialAggregate)); migrations.AddRange(startingMigrations); var migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStoreSession>().Get<TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "Loaded un-cached aggregate"); var migratedCachedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStoreSession>().Get<TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedCachedHistory, "Loaded cached aggregate"); Console.WriteLine(" Streaming all events in store"); var streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical(expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); Console.WriteLine(" Persisting migrations"); using(container.BeginScope()) { container.Resolve<IEventStore>().PersistMigrations(); } migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStoreSession>().Get<TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "Loaded aggregate"); Console.WriteLine("Streaming all events in store"); streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical( expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); Console.WriteLine(" Disable all migrations so that none are used when reading from the event stores"); migrations.Clear(); migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStoreSession>().Get<TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "loaded aggregate"); Console.WriteLine("Streaming all events in store"); streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical(expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); if(eventStoreType == typeof(SqlServerEventStore)) { Console.WriteLine("Clearing sql server eventstore cache"); container.ExecuteUnitOfWorkInIsolatedScope(() => ((SqlServerEventStore)container.Resolve<IEventStore>()).ClearCache()); migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStoreSession>().Get<TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "Loaded aggregate"); Console.WriteLine("Streaming all events in store"); streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve<IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical(expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); } }
public void SetupContainer() { Container = WebTestWiringHelper.CreateContainer(); _scope = Container.BeginScope(); }
private static void RunScenarioWithEventStoreType (MigrationScenario scenario, Type eventStoreType, WindsorContainer container, IList <IEventMigration> migrations, int indexOfScenarioInBatch) { var startingMigrations = migrations.ToList(); migrations.Clear(); var timeSource = container.Resolve <DummyTimeSource>(); IReadOnlyList <IAggregateRootEvent> eventsInStoreAtStart; using (container.BeginScope()) //Why is this needed? It fails without it but I do not understand why... { var eventStore = container.Resolve <IEventStore>(); eventsInStoreAtStart = eventStore.ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize(); } Console.WriteLine($"\n########Running Scenario {indexOfScenarioInBatch}"); var original = TestAggregate.FromEvents(DummyTimeSource.Now, scenario.AggregateId, scenario.OriginalHistory).History.ToList(); Console.WriteLine($"Original History: "); original.ForEach(e => Console.WriteLine($" {e}")); Console.WriteLine(); var initialAggregate = TestAggregate.FromEvents(timeSource, scenario.AggregateId, scenario.OriginalHistory); var expected = TestAggregate.FromEvents(timeSource, scenario.AggregateId, scenario.ExpectedHistory).History.ToList(); var expectedCompleteEventstoreStream = eventsInStoreAtStart.Concat(expected).ToList(); Console.WriteLine($"Expected History: "); expected.ForEach(e => Console.WriteLine($" {e}")); Console.WriteLine(); var initialAggregate2 = TestAggregate.FromEvents(timeSource, scenario.AggregateId, scenario.OriginalHistory); timeSource.UtcNow += 1.Hours();//Bump clock to ensure that times will be be wrong unless the time from the original events are used.. Console.WriteLine("Doing pure in memory "); IReadOnlyList <IAggregateRootEvent> otherHistory = SingleAggregateInstanceEventStreamMutator.MutateCompleteAggregateHistory( scenario.Migrations, initialAggregate2.History.Cast <AggregateRootEvent>().ToList()); AssertStreamsAreIdentical(expected, otherHistory, $"Direct call to SingleAggregateInstanceEventStreamMutator.MutateCompleteAggregateHistory"); container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Save(initialAggregate)); migrations.AddRange(startingMigrations); var migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Get <TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "Loaded un-cached aggregate"); var migratedCachedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Get <TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedCachedHistory, "Loaded cached aggregate"); Console.WriteLine(" Streaming all events in store"); var streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical(expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); Console.WriteLine(" Persisting migrations"); using (container.BeginScope()) { container.Resolve <IEventStore>().PersistMigrations(); } migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Get <TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "Loaded aggregate"); Console.WriteLine("Streaming all events in store"); streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical(expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); Console.WriteLine(" Disable all migrations so that none are used when reading from the event stores"); migrations.Clear(); migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Get <TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "loaded aggregate"); Console.WriteLine("Streaming all events in store"); streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical(expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); if (eventStoreType == typeof(SqlServerEventStore)) { Console.WriteLine("Clearing sql server eventstore cache"); container.ExecuteUnitOfWorkInIsolatedScope(() => ((SqlServerEventStore)container.Resolve <IEventStore>()).ClearCache()); migratedHistory = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Get <TestAggregate>(initialAggregate.Id)).History; AssertStreamsAreIdentical(expected, migratedHistory, "Loaded aggregate"); Console.WriteLine("Streaming all events in store"); streamedEvents = container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStore>().ListAllEventsForTestingPurposesAbsolutelyNotUsableForARealEventStoreOfAnySize().ToList()); AssertStreamsAreIdentical(expectedCompleteEventstoreStream, streamedEvents, "Streaming all events in store"); } }