Пример #1
0
        public void which_was_allready_deleted_should_fail()
        {
            const string stream = "which_was_allready_deleted_should_fail";

            using (var connection = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var create = connection.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

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

                var secondDelete = connection.DeleteStreamAsync(stream, ExpectedVersion.Any);
                Assert.That(() => secondDelete.Wait(), Throws.Exception.TypeOf <AggregateException>().With.InnerException.TypeOf <StreamDeletedException>());
            }
        }
Пример #2
0
        public void which_does_not_exist_should_fail()
        {
            const string stream = "which_does_not_exist_should_fail";

            using (var connection = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var delete = connection.DeleteStreamAsync(stream, ExpectedVersion.Any);
                Assert.Inconclusive();
                //Assert.That(() => delete.Wait(), Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<WrongExpectedVersionException>());
            }
        }
Пример #3
0
        public void with_invalid_expected_version_should_fail()
        {
            const string stream = "with_invalid_expected_version_should_fail";

            using (var connection = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var create = connection.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                var delete = connection.DeleteStreamAsync(stream, 1);
                Assert.That(() => delete.Wait(), Throws.Exception.TypeOf <AggregateException>().With.InnerException.TypeOf <WrongExpectedVersionException>());
            }
        }
Пример #4
0
        public void which_already_exists_should_success_when_passed_any_for_expected_version()
        {
            const string stream = "which_already_exists_should_success_when_passed_any_for_expected_version";

            using (var connection = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var create = connection.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                var delete = connection.DeleteStreamAsync(stream, ExpectedVersion.Any);
                Assert.DoesNotThrow(delete.Wait);
            }
        }
Пример #5
0
        public void should_fail_writing_with_invalid_exp_ver_to_deleted_stream()
        {
            const string stream = "should_fail_writing_with_invalid_exp_ver_to_deleted_stream";

            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var create = store.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

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

                var append = store.AppendToStreamAsync(stream, 5, new[] { new TestEvent() });
                Assert.That(() => append.Wait(), Throws.Exception.TypeOf <AggregateException>().With.InnerException.TypeOf <StreamDeletedException>());
            }
        }
Пример #6
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>());
            }
        }