public async Task return_events_in_correct_order_compared_to_written()
        {
            var events = await _fixture.Client
                         .ReadAllAsync(Direction.Forwards, Position.Start, _fixture.Events.Length * 2)
                         .ToArrayAsync();

            Assert.True(EventDataComparer.Equal(_fixture.Events, events.AsResolvedTestEvents().ToArray()));
        }
        public async Task return_events_in_reversed_order_compared_to_written()
        {
            var events = await _fixture.Client.ReadAllAsync(Direction.Backwards, Position.End, _fixture.Events.Length)
                         .ToArrayAsync();

            Assert.True(EventDataComparer.Equal(
                            _fixture.Events.Reverse().ToArray(),
                            events.AsResolvedTestEvents().ToArray()));
        }
        public async Task return_single_event()
        {
            var events = await _fixture.Client.ReadAllAsync(Direction.Backwards, Position.End, maxCount : 1)
                         .ToArrayAsync();

            var actualEvent = Assert.Single(events.AsResolvedTestEvents());

            Assert.True(EventDataComparer.Equal(
                            _fixture.Events.Last(),
                            actualEvent));
        }
        public async Task returns_events_in_order(string suffix, int count, int metadataSize)
        {
            var stream = $"{_fixture.GetStreamName()}_{suffix}";

            var expected = _fixture.CreateTestEvents(count: count, metadataSize: metadataSize).ToArray();

            await _fixture.Client.AppendToStreamAsync(stream, StreamState.NoStream, expected);

            var actual = await _fixture.Client
                         .ReadStreamAsync(Direction.Forwards, stream, StreamPosition.Start, expected.Length)
                         .Select(x => x.Event).ToArrayAsync();

            Assert.True(EventDataComparer.Equal(expected, actual));
        }
        public async Task be_able_to_read_from_arbitrary_position()
        {
            var stream = _fixture.GetStreamName();

            var events = _fixture.CreateTestEvents(10).ToArray();

            await _fixture.Client.AppendToStreamAsync(stream, StreamState.NoStream, events);

            var actual = await _fixture.Client.ReadStreamAsync(Direction.Forwards, stream, new StreamPosition(3), 2)
                         .Select(x => x.Event)
                         .ToArrayAsync();

            Assert.True(EventDataComparer.Equal(events.Skip(3).Take(2).ToArray(), actual));
        }
Exemple #6
0
        public async Task returns_events_in_order()
        {
            var stream = _fixture.GetStreamName();

            var expected = _fixture.CreateTestEvents(10).ToArray();

            await _fixture.Client.AppendToStreamAsync(stream, StreamState.NoStream, expected);

            var actual = await _fixture.Client
                         .ReadStreamAsync(Direction.Forwards, stream, StreamPosition.Start, (ulong)expected.Length)
                         .Select(x => x.Event).ToArrayAsync();

            Assert.True(EventDataComparer.Equal(expected, actual));
        }
        public async Task be_able_to_read_first_event()
        {
            var stream = _fixture.GetStreamName();

            var testEvents = _fixture.CreateTestEvents(10).ToArray();

            await _fixture.Client.AppendToStreamAsync(stream, StreamState.NoStream, testEvents);

            var events = await _fixture.Client.ReadStreamAsync(Direction.Forwards, stream, StreamPosition.Start, 1)
                         .Select(x => x.Event)
                         .ToArrayAsync();

            Assert.Single(events);
            Assert.True(EventDataComparer.Equal(testEvents[0], events[0]));
        }
        public async Task be_able_to_read_single_event_from_arbitrary_position()
        {
            var stream = _fixture.GetStreamName();

            var events = _fixture.CreateTestEvents(10).ToArray();

            var expected = events[7];

            await _fixture.Client.AppendToStreamAsync(stream, StreamState.NoStream, events);

            var actual = await _fixture.Client.ReadStreamAsync(Direction.Backwards, stream, new StreamPosition(7), 1)
                         .Select(x => x.Event)
                         .SingleAsync();

            Assert.True(EventDataComparer.Equal(expected, actual));
        }
Exemple #9
0
        public async Task read_stream_backwards_respects_max_count()
        {
            var stream = _fixture.GetStreamName();

            await _fixture.Client.SetStreamMetadataAsync(stream, StreamState.NoStream, new StreamMetadata(3));

            var expected = _fixture.CreateTestEvents(5).ToArray();

            await _fixture.Client.AppendToStreamAsync(stream, StreamState.NoStream, expected);

            var actual = await _fixture.Client.ReadStreamAsync(Direction.Backwards, stream, StreamPosition.End, 100)
                         .Select(x => x.Event)
                         .ToArrayAsync();

            Assert.Equal(3, actual.Length);
            Assert.True(EventDataComparer.Equal(expected.Skip(2).Reverse().ToArray(), actual));
        }
Exemple #10
0
        public async Task after_setting_more_strict_max_count_read_stream_forward_reads_less_events()
        {
            var stream = _fixture.GetStreamName();

            await _fixture.Client.SetStreamMetadataAsync(stream, StreamState.NoStream, new StreamMetadata(3));

            var expected = _fixture.CreateTestEvents(5).ToArray();

            await _fixture.Client.AppendToStreamAsync(stream, StreamState.NoStream, expected);

            await _fixture.Client.SetStreamMetadataAsync(stream, new StreamRevision(0), new StreamMetadata(2));

            var actual = await _fixture.Client.ReadStreamAsync(Direction.Forwards, stream, StreamPosition.Start, 100)
                         .Select(x => x.Event)
                         .ToArrayAsync();

            Assert.Equal(2, actual.Length);
            Assert.True(EventDataComparer.Equal(expected.Skip(3).ToArray(), actual));
        }