Beispiel #1
0
        public void should_create_stream_if_commits_no_events_to_empty_stream()
        {
            const string stream = "should_create_stream_if_commits_no_events_to_empty_stream";
            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var start = store.StartTransactionAsync(stream, ExpectedVersion.NoStream);
                Assert.DoesNotThrow(start.Wait);
                var commit = store.CommitTransactionAsync(start.Result.TransactionId, start.Result.Stream);
                Assert.DoesNotThrow(commit.Wait);

                var streamCreated = store.ReadEventStreamForwardAsync(stream, 0, 1);
                Assert.DoesNotThrow(streamCreated.Wait);

                Assert.That(streamCreated.Result.Events.Length, Is.EqualTo(1));//stream created event
            }
        }
Beispiel #2
0
 public void should_validate_expectations_on_commit()
 {
     const string stream = "should_validate_expectations_on_commit";
     using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
     {
         var start = store.StartTransactionAsync(stream, 100500);
         Assert.DoesNotThrow(start.Wait);
         var write = store.TransactionalWriteAsync(start.Result.TransactionId, stream, new[] { new TestEvent() });
         Assert.DoesNotThrow(write.Wait);
         var commit = store.CommitTransactionAsync(start.Result.TransactionId, start.Result.Stream);
         Assert.That(() => commit.Wait(), Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<WrongExpectedVersionException>());
     }
 }
Beispiel #3
0
        public void should_not_fail_to_commit_if_started_with_wrong_ver_but_committing_with_correct_ver()
        {
            const string stream = "should_not_fail_to_commit_if_started_with_wrong_ver_but_committing_with_correct_ver";
            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
                store.CreateStream(stream, new byte[0]);

            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var start = store.StartTransactionAsync(stream, 1);
                Assert.DoesNotThrow(start.Wait);

                var append = store.AppendToStreamAsync(stream, ExpectedVersion.EmptyStream, new[] { new TestEvent() });
                Assert.DoesNotThrow(append.Wait);

                var write = store.TransactionalWriteAsync(start.Result.TransactionId, start.Result.Stream, new[] { new TestEvent() });
                Assert.DoesNotThrow(write.Wait);

                var commit = store.CommitTransactionAsync(start.Result.TransactionId, start.Result.Stream);
                Assert.DoesNotThrow(commit.Wait);
            }
        }
Beispiel #4
0
 public void should_start_on_non_existing_stream_with_exp_ver_any_and_create_stream_on_commit()
 {
     const string stream = "should_start_on_non_existing_stream_with_exp_ver_any_and_create_stream_on_commit";
     using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
     {
         var start = store.StartTransactionAsync(stream, ExpectedVersion.Any);
         Assert.DoesNotThrow(start.Wait);
         var write = store.TransactionalWriteAsync(start.Result.TransactionId, stream, new[] {new TestEvent()});
         Assert.DoesNotThrow(write.Wait);
         var commit = store.CommitTransactionAsync(start.Result.TransactionId, start.Result.Stream);
         Assert.DoesNotThrow(commit.Wait);
     }
 }
Beispiel #5
0
        public void should_fail_to_commit_if_started_with_correct_ver_but_on_commit_stream_was_deleted()
        {
            const string stream = "should_fail_to_commit_if_started_with_correct_ver_but_on_commit_stream_was_deleted";
            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
                store.CreateStream(stream, new byte[0]);

            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var start = store.StartTransactionAsync(stream, ExpectedVersion.EmptyStream);
                Assert.DoesNotThrow(start.Wait);

                var write = store.TransactionalWriteAsync(start.Result.TransactionId, start.Result.Stream, new[] { new TestEvent() });
                Assert.DoesNotThrow(write.Wait);

                var delete = store.DeleteStreamAsync(stream, ExpectedVersion.EmptyStream);
                Assert.DoesNotThrow(delete.Wait);

                var commit = store.CommitTransactionAsync(start.Result.TransactionId, start.Result.Stream);
                Assert.That(() => commit.Wait(), Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<StreamDeletedException>());
            }
        }