예제 #1
0
        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);
        }
예제 #2
0
        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);            
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }