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 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); }