public void all_records_could_be_read_doing_forward_backward_pass() { var seqReader = new TFChunkSequentialReader(_db, _db.Config.WriterCheckpoint, 0); SeqReadResult res; int count1 = 0; while ((res = seqReader.TryReadNext()).Success) { var rec = _keptRecords[count1]; Assert.AreEqual(rec, res.LogRecord); //Assert.AreEqual(rec.Position + rec.GetSizeWithLengthPrefixAndSuffix(), seqReader.Position); ++count1; } Assert.AreEqual(_keptRecords.Length, count1); int count2 = 0; while ((res = seqReader.TryReadPrev()).Success) { var rec = _keptRecords[_keptRecords.Length - count2 - 1]; Assert.AreEqual(rec, res.LogRecord); //Assert.AreEqual(rec.Position, seqReader.Position); ++count2; } Assert.AreEqual(_keptRecords.Length, count2); }
public void all_records_could_be_read_with_backward_pass() { var seqReader = new TFChunkSequentialReader(_db, _db.Config.WriterCheckpoint, _db.Config.WriterCheckpoint.Read()); SeqReadResult res; int count = 0; while ((res = seqReader.TryReadPrev()).Success) { var rec = _keptRecords[_keptRecords.Length - count - 1]; Assert.AreEqual(rec, res.LogRecord); Assert.AreEqual(rec.Position, res.RecordPrePosition); Assert.AreEqual(rec.Position + rec.GetSizeWithLengthPrefixAndSuffix(), res.RecordPostPosition); ++count; } Assert.AreEqual(_keptRecords.Length, count); }
public void records_can_be_read_backward_starting_from_any_position() { for (int i = 0; i < RecordsCount; ++i) { var seqReader = new TFChunkSequentialReader(_db, _db.Config.WriterCheckpoint, _records[i].Position); SeqReadResult res; int count = 0; while ((res = seqReader.TryReadPrev()).Success) { var rec = _keptRecords[i/2 - count - 1]; Assert.AreEqual(rec, res.LogRecord); Assert.AreEqual(rec.Position, res.RecordPrePosition); Assert.AreEqual(rec.Position + rec.GetSizeWithLengthPrefixAndSuffix(), res.RecordPostPosition); ++count; } Assert.AreEqual(i/2, count); } }