public void EnumeratorResetShouldDoNothing() { var records = RecordCreator.CreateRecords(5); var recordSet = new ListBasedRecordSet(records); var ex = Xunit.Record.Exception(() => recordSet.Records().GetEnumerator().Reset()); ex.Should().BeOfType <NotSupportedException>(); }
public void ShouldReturnRecordsInOrder() { var records = RecordCreator.CreateRecords(5); var recordSet = new ListBasedRecordSet(records); int i = 0; foreach (var record in recordSet.Records()) { record[0].As <string>().Should().Be($"record{i++}:key0"); } i.Should().Be(5); }
public void ShouldGetTheFirstRecordAndMoveToNextPosition() { var records = RecordCreator.CreateRecords(5); var recordSet = new ListBasedRecordSet(records); var recordStream = recordSet.Records(); var record = recordStream.First(); record[0].As <string>().Should().Be("record0:key0"); record = recordStream.First(); record[0].As <string>().Should().Be("record1:key0"); }
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(); }
public void ShouldAlwaysAdvanceRecordPosition() { var recordSet = new ListBasedRecordSet(RecordCreator.CreateRecords(5)); var recordStream = recordSet.Records(); var enumerable = recordStream.Take(1); var records = recordStream.Take(2).ToList(); records[0][0].As <string>().Should().Be("record0:key0"); records[1][0].As <string>().Should().Be("record1:key0"); records = enumerable.ToList(); records[0][0].As <string>().Should().Be("record2:key0"); }
public void ShouldReturnNextRecordAfterNextWithoutMovingCurrentRecord() { var records = RecordCreator.CreateRecords(5); var recordSet = new ListBasedRecordSet(records); recordSet.Records().Take(1).ToList(); var record = recordSet.Peek(); record.Should().NotBeNull(); record[0].As <string>().Should().Be("record1:key0"); // not moving further no matter how many times are called record = recordSet.Peek(); record.Should().NotBeNull(); record[0].As <string>().Should().Be("record1:key0"); }
public void ShouldReturnRecordsAddedLatter() { var keys = RecordCreator.CreateKeys(); var records = RecordCreator.CreateRecords(5, keys); var recordSet = new ListBasedRecordSet(records); // I add a new record after RecordSet is created var newRecord = new Record(keys.ToArray(), new object[] { "record5:key0" }); records.Add(newRecord); int i = 0; foreach (var record in recordSet.Records()) { record[0].As <string>().Should().Be($"record{i++}:key0"); } i.Should().Be(6); }