Ejemplo n.º 1
0
        public void return_correct_range_on_from_end_range_query_for_second_stream_with_specific_version()
        {
            var result = ReadIndex.ReadStreamEventsBackward("CD", 4, 5);

            Assert.AreEqual(ReadStreamResult.Success, result.Result);
            Assert.AreEqual(5, result.Records.Length);

            var records = result.Records.Reverse().ToArray();

            for (int i = 0; i < _prepares2.Length; i++)
            {
                Assert.AreEqual(_prepares2[i], records[i]);
            }
        }
Ejemplo n.º 2
0
        public void return_correct_range_on_from_end_range_query_for_first_stream_with_from_end_version()
        {
            var result = ReadIndex.ReadStreamEventsBackward("AB", -1, 3);

            Assert.AreEqual(ReadStreamResult.Success, result.Result);
            Assert.AreEqual(3, result.Records.Length);

            var records = result.Records.Reverse().ToArray();

            for (int i = 0; i < _prepares1.Length; i++)
            {
                Assert.AreEqual(_prepares1[i], records[i]);
            }
        }
        public void return_correct_range_on_from_end_range_query_for_third_stream_from_specific_version()
        {
            var result = ReadIndex.ReadStreamEventsBackward("EF", 6, 7);

            Assert.AreEqual(RangeReadResult.Success, result.Result);
            Assert.AreEqual(7, result.Records.Length);

            var records = result.Records.Reverse().ToArray();

            for (int i = 0; i < _prepares3.Length; i++)
            {
                Assert.AreEqual(_prepares3[i], records[i]);
            }
        }
Ejemplo n.º 4
0
        public void on_read_backward_from_end_to_active_next_event_number_is_last_read_event_minus_1_and_its_not_end_of_stream()
        {
            var res = ReadIndex.ReadStreamEventsBackward("ES", 4, 2);

            Assert.AreEqual(ReadStreamResult.Success, res.Result);
            Assert.AreEqual(2, res.NextEventNumber);
            Assert.AreEqual(4, res.LastEventNumber);
            Assert.IsFalse(res.IsEndOfStream);

            var records = res.Records;

            Assert.AreEqual(2, records.Length);
            Assert.AreEqual(_event5, records[0]);
            Assert.AreEqual(_event4, records[1]);
        }
Ejemplo n.º 5
0
        public void on_read_backward_from_active_to_expired_its_end_of_stream()
        {
            var res = ReadIndex.ReadStreamEventsBackward("ES", 3, 3);

            Assert.AreEqual(ReadStreamResult.Success, res.Result);
            Assert.AreEqual(-1, res.NextEventNumber);
            Assert.AreEqual(4, res.LastEventNumber);
            Assert.IsTrue(res.IsEndOfStream);

            var records = res.Records;

            Assert.AreEqual(2, records.Length);
            Assert.AreEqual(_event4, records[0]);
            Assert.AreEqual(_event3, records[1]);
        }
        public void on_read_backward_from_out_of_bounds_to_middle_next_event_number_is_middle_minus_1_and_its_not_end_of_stream()
        {
            var res = ReadIndex.ReadStreamEventsBackward("ES", 7, 5);

            Assert.AreEqual(RangeReadResult.Success, res.Result);
            Assert.AreEqual(2, res.NextEventNumber);
            Assert.AreEqual(5, res.LastEventNumber);
            Assert.IsFalse(res.IsEndOfStream);

            var records = res.Records;

            Assert.AreEqual(3, records.Length);
            Assert.AreEqual(_event5, records[0]);
            Assert.AreEqual(_event4, records[1]);
            Assert.AreEqual(_event3, records[2]);
        }
        public void on_read_backward_from_end_to_maxcount_bound_its_end_of_stream()
        {
            var res = ReadIndex.ReadStreamEventsBackward("ES", 5, 3);

            Assert.AreEqual(RangeReadResult.Success, res.Result);
            Assert.AreEqual(-1, res.NextEventNumber);
            Assert.AreEqual(5, res.LastEventNumber);
            Assert.IsTrue(res.IsEndOfStream);

            var records = res.Records;

            Assert.AreEqual(3, records.Length);
            Assert.AreEqual(_event5, records[0]);
            Assert.AreEqual(_event4, records[1]);
            Assert.AreEqual(_event3, records[2]);
        }
        on_read_backward_from_the_end_to_middle_next_event_number_is_middle_minus_1_and_its_not_end_of_stream()
        {
            var res = ReadIndex.ReadStreamEventsBackward("ES", 4, 3);

            Assert.AreEqual(ReadStreamResult.Success, res.Result);
            Assert.AreEqual(1, res.NextEventNumber);
            Assert.AreEqual(4, res.LastEventNumber);
            Assert.IsFalse(res.IsEndOfStream);

            var records = res.Records;

            Assert.AreEqual(3, records.Length);
            Assert.AreEqual(_event4, records[0]);
            Assert.AreEqual(_event3, records[1]);
            Assert.AreEqual(_event2, records[2]);
        }
Ejemplo n.º 9
0
        public void on_read_backward_from_end_to_maxage_bound_next_event_number_is_maxage_bound_minus_1_and_its_not_end_of_stream() // just no simple way to tell this
        {
            var res = ReadIndex.ReadStreamEventsBackward("ES", 4, 3);

            Assert.AreEqual(ReadStreamResult.Success, res.Result);
            Assert.AreEqual(1, res.NextEventNumber);
            Assert.AreEqual(4, res.LastEventNumber);
            Assert.IsFalse(res.IsEndOfStream);

            var records = res.Records;

            Assert.AreEqual(3, records.Length);
            Assert.AreEqual(_event4, records[0]);
            Assert.AreEqual(_event3, records[1]);
            Assert.AreEqual(_event2, records[2]);
        }
        public void on_read_backward_from_middle_to_before_start_next_event_number_is_minus_1_and_its_end_of_stream()
        {
            var res = ReadIndex.ReadStreamEventsBackward("ES", 2, 5);

            Assert.AreEqual(ReadStreamResult.Success, res.Result);
            Assert.AreEqual(-1, res.NextEventNumber);
            Assert.AreEqual(4, res.LastEventNumber);
            Assert.IsTrue(res.IsEndOfStream);

            var records = res.Records;

            Assert.AreEqual(3, records.Length);
            Assert.AreEqual(_event2, records[0]);
            Assert.AreEqual(_event1, records[1]);
            Assert.AreEqual(_event0, records[2]);
        }
        public void reading_forward_should_match_reading_backwards_in_reverse()
        {
            var backwardsCollected = new List <EventRecord>();
            var forwardsCollected  = new List <EventRecord>();
            var from = long.MaxValue;

            while (true)
            {
                var backwards = ReadIndex.ReadStreamEventsBackward("ES", from, 7);
                for (int i = 0; i < backwards.Records.Length; i++)
                {
                    backwardsCollected.Add(backwards.Records[i]);
                }

                from = backwards.NextEventNumber;
                if (backwards.IsEndOfStream)
                {
                    break;
                }
            }

            from = 0;
            while (true)
            {
                var forwards = ReadIndex.ReadStreamEventsForward("ES", from, 7);
                for (int i = 0; i < forwards.Records.Length; i++)
                {
                    forwardsCollected.Add(forwards.Records[i]);
                }

                from = forwards.NextEventNumber;
                if (forwards.IsEndOfStream)
                {
                    break;
                }
            }

            Assert.AreEqual(forwardsCollected.Count, backwardsCollected.Count);
            backwardsCollected.Reverse();
            for (int i = 0; i < backwardsCollected.Count; i++)
            {
                Assert.AreEqual(backwardsCollected[i].EventId, forwardsCollected[i].EventId);
                Assert.AreEqual(backwardsCollected[i].EventType, forwardsCollected[i].EventType);
                Assert.AreEqual(backwardsCollected[i].ExpectedVersion, forwardsCollected[i].ExpectedVersion);
                Assert.AreEqual(backwardsCollected[i].EventNumber, forwardsCollected[i].EventNumber);
            }
        }
 public void the_metastream_is_absent_logically()
 {
     Assert.AreEqual(ReadEventResult.NotFound, ReadIndex.ReadEvent("$$test", 0).Result);
     Assert.AreEqual(ReadStreamResult.Success, ReadIndex.ReadStreamEventsForward("$$test", 0, 100).Result);
     Assert.AreEqual(ReadStreamResult.Success, ReadIndex.ReadStreamEventsBackward("$$test", -1, 100).Result);
 }
 public void the_stream_returns_nothing_for_nonexistent_page()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.Success, ReadIndex.ReadStreamEventsBackward("test1", 100, 10, out records));
     Assert.AreEqual(0, records.Length);
 }
Ejemplo n.º 14
0
 public void return_empty_range_for_5_1_range_on_from_end_range_query_request_for_second_stream()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.Success, ReadIndex.ReadStreamEventsBackward("CD", 5, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
Ejemplo n.º 15
0
 public void return_empty_5_1_range_on_from_end_range_query_for_non_existing_stream_with_same_hash_as_second_one()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.NoStream, ReadIndex.ReadStreamEventsBackward("FY", 5, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
 public void not_return_range_for_non_existing_stream_with_same_hash()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.NoStream, ReadIndex.ReadStreamEventsBackward("EF", 0, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
Ejemplo n.º 17
0
 public void return_empty_range_for_7_1_range_on_from_end_range_query_request_for_third_stream()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.StreamDeleted, ReadIndex.ReadStreamEventsBackward("EF", 7, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
 public void not_return_range_on_from_end_query_with_from_end_version_for_non_existing_stream_with_same_hash_as_stream_with_two_events()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.NoStream, ReadIndex.ReadStreamEventsBackward("NONE", -1, 2, out records));
     Assert.AreEqual(0, records.Length);
 }
 public void return_empty_range_on_try_get_records_from_end_for_nonexisting_stream()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.NoStream, ReadIndex.ReadStreamEventsBackward("ES-NONEXISTING", 0, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
 public void return_empty_range_on_try_get_records_from_end_for_nonexisting_event_stream_with_same_hash_as_existing_one()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.NoStream, ReadIndex.ReadStreamEventsBackward("HG", 0, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
 public void return_empty_range_on_from_end_range_query_for_invalid_arguments_for_first_stream()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.Success, ReadIndex.ReadStreamEventsBackward("AB", 1, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
 public void return_correct_range_on_from_end_range_query_for_first_stream()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.Success, ReadIndex.ReadStreamEventsBackward("AB", 0, 1, out records));
     Assert.AreEqual(_prepare1, records[0]);
 }
 public void the_kept_stream_is_present()
 {
     Assert.AreEqual(ReadEventResult.Success, ReadIndex.ReadEvent(_keptStream, 0).Result);
     Assert.AreEqual(ReadStreamResult.Success, ReadIndex.ReadStreamEventsForward(_keptStream, 0, 100).Result);
     Assert.AreEqual(ReadStreamResult.Success, ReadIndex.ReadStreamEventsBackward(_keptStream, -1, 100).Result);
 }
 public void the_stream_is_absent_logically()
 {
     Assert.AreEqual(ReadEventResult.NoStream, ReadIndex.ReadEvent("test", 0).Result);
     Assert.AreEqual(ReadStreamResult.NoStream, ReadIndex.ReadStreamEventsForward("test", 0, 100).Result);
     Assert.AreEqual(ReadStreamResult.NoStream, ReadIndex.ReadStreamEventsBackward("test", -1, 100).Result);
 }
Ejemplo n.º 25
0
        public void return_empty_range_on_from_end_range_query_for_second_stream()
        {
            var result = ReadIndex.ReadStreamEventsBackward("CD", 0, 1);

            Assert.AreEqual(RangeReadResult.StreamDeleted, result.Result);
        }
 public void the_stream_cant_be_read_for_second_stream()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.NoStream, ReadIndex.ReadStreamEventsBackward("test2", 0, 1, out records));
     Assert.AreEqual(0, records.Length);
 }
Ejemplo n.º 27
0
 public void read_stream_events_backward_reports_deleted_metastream()
 {
     Assert.AreEqual(ReadStreamResult.StreamDeleted, ReadIndex.ReadStreamEventsBackward("$$test", 0, 100).Result);
 }
        public void should_be_able_to_read_stream_events_backward()
        {
            var result = ReadIndex.ReadStreamEventsBackward(_stream, -1, 10);

            Assert.AreEqual(2, result.Records.Length);
        }
 public void the_stream_is_absent_logically()
 {
     Assert.AreEqual(ReadStreamResult.NoStream, ReadIndex.ReadStreamEventsForward("test", 0, 100).Result, "Read test stream forward");
     Assert.AreEqual(ReadStreamResult.NoStream, ReadIndex.ReadStreamEventsBackward("test", -1, 100).Result, "Read test stream backward");
     Assert.AreEqual(ReadEventResult.NoStream, ReadIndex.ReadEvent("test", 0).Result, "Read single event from test stream");
 }
Ejemplo n.º 30
0
 public void return_empty_7_1_range_on_from_end_range_query_for_non_existing_stream_with_same_hash_as_third_one()
 {
     EventRecord[] records;
     Assert.AreEqual(RangeReadResult.StreamDeleted, ReadIndex.ReadStreamEventsBackward("EF", 7, 1, out records));
     Assert.AreEqual(0, records.Length);
 }