public void VariableLengthRecordTest2() { var recordFile = new VariableLengthRecordFile("C:/Persistence", "VariableRecordFile"); Assert.IsTrue(recordFile.GetBytesUsed() == 43); Assert.IsTrue(recordFile.GetBytesTotal() == 47); var record = new VariableLengthRecord(); record.AppendValue(10000); record.AppendValue(20000); record.AppendValue(30000); record.AppendValue(40000); int offset = 0; int dataSizeBytes = 0; Assert.IsTrue(recordFile.Append(record, ref offset, ref dataSizeBytes)); Assert.AreEqual(offset, 47); Assert.AreEqual(dataSizeBytes, 60); int bytesUsed2 = recordFile.GetBytesUsed(); Assert.AreEqual(bytesUsed2, 103); int bytesTotal2 = recordFile.GetBytesTotal(); Assert.AreEqual(recordFile.GetBytesTotal(), 107); recordFile.Close(); }
public void VariableLengthRecordTest1() { TestInitialize(); var recordFile = new VariableLengthRecordFile("C:/Persistence", "VariableRecordFile"); Assert.IsTrue(recordFile.GetBytesUsed() == 0); int totalBytes = recordFile.GetBytesTotal(); Assert.IsTrue(totalBytes == 4); // Four bytes in file header contain # of used bytes var record1 = new VariableLengthRecord(); record1.AppendValue(1000); record1.AppendValue(2000); record1.AppendValue(3000); int offset = 0; int dataSizeBytes = 0; Assert.IsTrue(recordFile.Append(record1, ref offset, ref dataSizeBytes)); Assert.AreEqual(offset, 4); Assert.AreEqual(dataSizeBytes, 43); Assert.AreEqual(recordFile.GetBytesUsed(), 43); int total = recordFile.GetBytesTotal(); Assert.AreEqual(total, 47); recordFile.Close(); }