예제 #1
0
            public void ShouldBeTheSameWithEnumeratorMoveNextCurrent()
            {
                var records   = RecordCreator.CreateRecords(2);
                var recordSet = new ListBasedRecordSet(records);

                IRecord record;
                IEnumerator <IRecord> enumerator;

                for (int i = 0; i < 2; i++)
                {
                    record = recordSet.Peek();
                    record.Should().NotBeNull();
                    record[0].As <string>().Should().Be($"record{i}:key0");

                    enumerator = recordSet.Records().GetEnumerator();
                    enumerator.MoveNext().Should().BeTrue();

                    // peeked record = current
                    enumerator.Current[0].As <string>().Should().Be($"record{i}:key0");
                }

                record = recordSet.Peek();
                record.Should().BeNull();

                enumerator = recordSet.Records().GetEnumerator();
                enumerator.MoveNext().Should().BeFalse();
                enumerator.Current.Should().BeNull();
            }
예제 #2
0
            public void ShouldReturnNextRecordWithoutMovingCurrentRecord()
            {
                var records   = RecordCreator.CreateRecords(5);
                var recordSet = new ListBasedRecordSet(records);

                var record = recordSet.Peek();

                record.Should().NotBeNull();
                record[0].As <string>().Should().Be("record0:key0");

                // not moving further no matter how many times are called
                record = recordSet.Peek();
                record.Should().NotBeNull();
                record[0].As <string>().Should().Be("record0:key0");
            }
예제 #3
0
            public void ShouldReturnNullIfAtEnd()
            {
                var records   = RecordCreator.CreateRecords(5);
                var recordSet = new ListBasedRecordSet(records);

                recordSet.Records().Take(4).ToList(); // [0, 1, 2, 3]

                var record = recordSet.Peek();

                record.Should().NotBeNull();
                record[0].As <string>().Should().Be("record4:key0");

                var moveNext = recordSet.Records().GetEnumerator().MoveNext();

                moveNext.Should().BeTrue();

                record.Should().NotBeNull();
                record[0].As <string>().Should().Be("record4:key0");

                record = recordSet.Peek();
                record.Should().BeNull();
            }