public void CanReadSetBlobRecord() { var block = new Block(RandomFilename, 0); var rec = new SetBlobRecord(_logManager, _bufferManager, 5, block, 0, new byte[] { 1, 2, 3 }); var lsn = rec.WriteToLog(); _logManager.Flush(lsn); _enumerator = new LogRecordEnumerator(_logManager, _bufferManager); var record = _enumerator.Current as SetBlobRecord; Assert.AreEqual(LogRecordType.SetBlob, record.Type); Assert.AreEqual(5, record.TransactionNumber); Assert.AreEqual(block, record.Block); Assert.AreEqual(0, record.Offset); Assert.AreEqual(new byte[] { 1, 2, 3 }, record.Value); }
public void CanWriteSetBlobRecordMultipleTimesToLog() { _logRecord = new SetBlobRecord( _logManager, _bufferManager, 1, _putToBlock, 0, new byte[] { 4, 5, 6 }); var logRecord2 = new SetBlobRecord( _logManager, _bufferManager, 1, _putToBlock, 0, new byte[] { 1, 2, 3 }); _ = _logRecord.WriteToLog(); var lsn2 = logRecord2.WriteToLog(); _logManager.Flush(lsn2); var enumerator = _logManager.GetEnumerator(); var record = enumerator.Current; var currentRecord2 = new SetBlobRecord(_logManager, _bufferManager, record); enumerator.MoveNext(); record = enumerator.Current; var currentRecord1 = new SetBlobRecord(_logManager, _bufferManager, record); Assert.IsNotNull(currentRecord2); Assert.AreEqual(LogRecordType.SetBlob, currentRecord2.Type); Assert.AreEqual(1, currentRecord1.TransactionNumber); Assert.AreEqual(new byte[] { 1, 2, 3 }, currentRecord2.Value); Assert.AreEqual(_putToBlock, currentRecord2.Block); Assert.AreEqual(0, currentRecord2.Offset); Assert.IsNotNull(currentRecord1); Assert.AreEqual(LogRecordType.SetBlob, currentRecord1.Type); Assert.AreEqual(1, currentRecord1.TransactionNumber); Assert.AreEqual(new byte[] { 4, 5, 6 }, currentRecord1.Value); Assert.AreEqual(_putToBlock, currentRecord1.Block); Assert.AreEqual(0, currentRecord1.Offset); }