public void ShouldSaveThreeTransitionsTest() { var streamId = Guid.NewGuid().ToString(); var repository = new MongoTransitionRepository( new AssemblyQualifiedDataTypeRegistry(), Helper.GetConnectionString()); var events = new List <TransitionEvent> { new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(1), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(2), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(3), null) }; var transitions = new List <Transition> { new Transition(new TransitionId(streamId, 1), DateTime.UtcNow, events, null), new Transition(new TransitionId(streamId, 2), DateTime.UtcNow, events, null), new Transition(new TransitionId(streamId, 3), DateTime.UtcNow, events, null) }; repository.SaveTransition(transitions[0]); repository.SaveTransition(transitions[1]); repository.SaveTransition(transitions[2]); var storedTransitions = repository.GetTransitions(streamId, 0, int.MaxValue); TransitionAsserter.AssertTransitions(transitions, storedTransitions); repository.RemoveStream(streamId); }
public void ShouldSaveThreeTransitionsTest() { var streamId = Guid.NewGuid().ToString(); var repository = new MongoTransitionRepository( new AssemblyQualifiedDataTypeRegistry(), Helper.GetConnectionString()); var events = new List<TransitionEvent>{ new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(1), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(2), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(3), null) }; var transitions = new List<Transition>{ new Transition(new TransitionId(streamId, 1), DateTime.UtcNow, events, null), new Transition(new TransitionId(streamId, 2), DateTime.UtcNow, events, null), new Transition(new TransitionId(streamId, 3), DateTime.UtcNow, events, null) }; repository.SaveTransition(transitions[0]); repository.SaveTransition(transitions[1]); repository.SaveTransition(transitions[2]); var storedTransitions = repository.GetTransitions(streamId, 0, int.MaxValue); TransitionAsserter.AssertTransitions(transitions, storedTransitions); repository.RemoveStream(streamId); }
public void ShouldThrowIfSuchVersionExists() { var streamId = Guid.NewGuid().ToString(); var repository = new MongoTransitionRepository( new AssemblyQualifiedDataTypeRegistry(), Helper.GetConnectionString()); var events = new List <TransitionEvent> { new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(1), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(2), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(3), null) }; var transitions = new List <Transition> { new Transition(new TransitionId(streamId, 1), DateTime.UtcNow, events, null), new Transition(new TransitionId(streamId, 1), DateTime.UtcNow, events, null) // Already existed version specified! }; repository.SaveTransition(transitions[0]); Assert.Throws <DuplicateTransitionException>(() => repository.SaveTransition(transitions[0])); repository.RemoveStream(streamId); }
public void ConfigureEventStore(IContainer container) { var settings = container.GetInstance <SiteSettings>(); var dispatcher = container.GetInstance <IDispatcher>(); var transitionsRepository = new MongoTransitionRepository(settings.MongoEventsConnectionString); container.Configure(config => { config.For <ITransitionRepository>().Singleton().Use(transitionsRepository); config.For <IEventBus>().Singleton().Use(new DispatcherEventBus(dispatcher)); config.For <IRepository>().Use <Repository>(); config.For(typeof(IRepository <>)).Use(typeof(Repository <>)); }); }
public void ShouldThrowIfSuchVersionExists() { var streamId = Guid.NewGuid().ToString(); var repository = new MongoTransitionRepository( new AssemblyQualifiedDataTypeRegistry(), Helper.GetConnectionString()); var events = new List<TransitionEvent> { new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(1), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(2), null), new TransitionEvent(typeof(StreamCreatedEvent).AssemblyQualifiedName, TransitionAsserter.CreatedStreamCreatedEvent(3), null) }; var transitions = new List<Transition> { new Transition(new TransitionId(streamId, 1), DateTime.UtcNow, events, null), new Transition(new TransitionId(streamId, 1), DateTime.UtcNow, events, null) // Already existed version specified! }; repository.SaveTransition(transitions[0]); Assert.Throws<DuplicateTransitionException>(() => repository.SaveTransition(transitions[0])); repository.RemoveStream(streamId); }