示例#1
0
        public void which_already_exists_should_fail()
        {
            const string stream = "which_already_exists_should_fail";
            using (var connection = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var initialCreate = connection.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(initialCreate.Wait);

                var secondCreate = connection.CreateStreamAsync(stream, new byte[0]);
                Assert.Inconclusive();
                //Assert.That(() => secondCreate.Wait(), Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<WrongExpectedVersionException>());
            }
        }
示例#2
0
        public void which_was_deleted_should_fail()
        {
            const string stream = "which_was_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 secondCreate = connection.CreateStreamAsync(stream, new byte[0]);
                Assert.That(() => secondCreate.Wait(), Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<StreamDeletedException>());
            }
        }
示例#3
0
 public void which_supposed_to_be_system_should_succees__but_on_your_own_risk()
 {
     const string stream = "$which_supposed_to_be_system_should_succees__but_on_your_own_risk";
     using (var connection = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
     {
         var create = connection.CreateStreamAsync(stream, new byte[0]);
         Assert.DoesNotThrow(create.Wait);
     }
 }
示例#4
0
 public void which_does_not_exist_should_be_successfull()
 {
     const string stream = "which_does_not_exist_should_be_successfull";
     using (var connection = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
     {
         var create = connection.CreateStreamAsync(stream, new byte[0]);
         Assert.DoesNotThrow(create.Wait);
     }
 }
示例#5
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>());
            }
        }
示例#6
0
        public void which_already_exists_should_success_when_passed_empty_stream_expected_version()
        {
            const string stream = "which_already_exists_should_success_when_passed_empty_stream_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.EmptyStream);
                Assert.DoesNotThrow(delete.Wait);
            }
        }
示例#7
0
        public void should_append_with_correct_exp_ver_to_existing_stream()
        {
            const string stream = "should_append_with_correct_exp_ver_to_existing_stream";
            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var create = store.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                var append = store.AppendToStreamAsync(stream, ExpectedVersion.EmptyStream, new[] { new TestEvent() });
                Assert.DoesNotThrow(append.Wait);
            }
        }
示例#8
0
        public void can_append_multiple_events_at_once()
        {
            const string stream = "can_append_multiple_events_at_once";
            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var create = store.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                var events = Enumerable.Range(0, 100).Select(i => new TestEvent(i.ToString(), i.ToString()));
                var append = store.AppendToStreamAsync(stream, ExpectedVersion.EmptyStream, events);
                Assert.DoesNotThrow(append.Wait);
            }
        }
示例#9
0
 public static Task CreateStreamAsync(string stream, byte[] metadata)
 {
     return(_connection.CreateStreamAsync(stream, metadata));
 }
示例#10
0
        public void should_fail_appending_with_wrong_exp_ver_to_existing_stream()
        {
            const string stream = "should_fail_appending_with_wrong_exp_ver_to_existing_stream";
            using (var store = new EventStoreConnection(MiniNode.Instance.TcpEndPoint))
            {
                var create = store.CreateStreamAsync(stream, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                var append = store.AppendToStreamAsync(stream, 1, new[] { new TestEvent() });
                Assert.That(() => append.Wait(), Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<WrongExpectedVersionException>());
            }
        }