public void sequence_0em1_1e0_2e1_3e2_4e3_5e4_0e5_non_idempotent()
        {
            const string stream = "appending_to_implicitly_created_stream_sequence_0em1_1e0_2e1_3e2_4e3_5e4_0e5_non_idempotent";
            using (var store = TestConnection.Create(_node.TcpEndPoint))
            {
                store.ConnectAsync().Wait();

                var events = Enumerable.Range(0, 6).Select(x => TestEvent.NewTestEvent(Guid.NewGuid())).ToArray();
                var writer = new StreamWriter(store, stream, -1);

                Assert.DoesNotThrow(() => writer.Append(events).Then(events.First(), 5));

                var total = EventsStream.Count(store, stream);
                Assert.That(total, Is.EqualTo(events.Length + 1));
            }
        }
        public void sequence_0_1e0_2e1_3e2_4e3_5e4_6e5_1e0_idempotent()
        {
            const string stream = "appending_to_explicitly_created_stream_sequence_0_1e0_2e1_3e2_4e3_5e4_6e5_1e0_idempotent";
            using (var store = EventStoreConnection.Create())
            {
                store.Connect(_node.TcpEndPoint);
                var create = store.CreateStreamAsync(stream, Guid.NewGuid(), false, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                var events = Enumerable.Range(1, 6).Select(x => TestEvent.NewTestEvent(Guid.NewGuid())).ToArray();
                var writer = new StreamWriter(store, stream, 0);

                Assert.DoesNotThrow(() => writer.Append(events).Then(events.First(), 0));

                var total = EventsStream.Count(store, stream);
                Assert.That(total, Is.EqualTo(events.Length + 1));
            }
        }
        public void sequence_0_1e0_2e1_3e2_4e3_5e4_6e5_1e5_wev()
        {
            const string stream = "appending_to_explicitly_created_stream_sequence_0_1e0_2e1_3e2_4e3_5e4_6e5_1e5_wev";
            using (var store = EventStoreConnection.Create())
            {
                store.Connect(_node.TcpEndPoint);
                var create = store.CreateStreamAsync(stream, Guid.NewGuid(), false, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                var events = Enumerable.Range(1, 6).Select(x => TestEvent.NewTestEvent(Guid.NewGuid())).ToArray();
                var writer = new StreamWriter(store, stream, 0);

                var first6 = writer.Append(events);
                Assert.That(() => first6.Then(events.First(), 5), Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<WrongExpectedVersionException>());
            }
        }
        public void sequence_0em1_1e0_2e1_3e2_4e3_5e4_0e6_wev()
        {
            const string stream = "appending_to_implicitly_created_stream_sequence_0em1_1e0_2e1_3e2_4e3_5e4_0e6_wev";
            using (var store = TestConnection.Create(_node.TcpEndPoint))
            {
                store.ConnectAsync().Wait();

                var events = Enumerable.Range(0, 6).Select(x => TestEvent.NewTestEvent(Guid.NewGuid())).ToArray();
                var writer = new StreamWriter(store, stream, -1);

                var first6 = writer.Append(events);
                Assert.That(() => first6.Then(events.First(), 6), 
                            Throws.Exception.TypeOf<AggregateException>().With.InnerException.TypeOf<WrongExpectedVersionException>());
            }
        }
        public void sequence_0em1_1e0_2e1_1any_1any_idempotent()
        {
            const string stream = "appending_to_implicitly_created_stream_sequence_0em1_1e0_2e1_1any_1any_idempotent";
            using (var store = BuildConnection(_node))
            {
                store.ConnectAsync().Wait();

                var events = Enumerable.Range(0, 3).Select(x => TestEvent.NewTestEvent(Guid.NewGuid())).ToArray();
                var writer = new StreamWriter(store, stream, -1);

                Assert.DoesNotThrow(() => writer.Append(events).Then(events[1], ExpectedVersion.Any).Then(events[1], ExpectedVersion.Any));

                var total = EventsStream.Count(store, stream);
                Assert.That(total, Is.EqualTo(events.Length));
            }
        }
        public void sequence_1em1_1any_idempotent()
        {
            const string stream = "appending_to_implicitly_created_stream_sequence_1em1_1any_idempotent";
            using (var store = EventStoreConnection.Create())
            {
                store.Connect(_node.TcpEndPoint);

                var events = Enumerable.Range(1, 1).Select(x => TestEvent.NewTestEvent(Guid.NewGuid())).ToArray();
                var writer = new StreamWriter(store, stream, -1);

                Assert.DoesNotThrow(() => writer.Append(events).Then(events.First(), ExpectedVersion.Any));

                var total = EventsStream.Count(store, stream);
                Assert.That(total, Is.EqualTo(events.Length + 1));
            }
        }