public void CanSetString() { var page = _fileManager.ResolvePage(); var block = new Block(RandomFilename, 0); page.Read(block); page.SetString(0, "default string"); page.Write(block); _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6); var buffer = _bufferManager.Pin(block); var lsn = _recoveryManager.SetString(buffer, 0, "not default string"); _logManager.Flush(lsn); _bufferManager.Unpin(buffer); _bufferManager.FlushAll(6); var enumerator = _logManager.GetEnumerator(); var record = enumerator.Current; var setBoolRecord = new SetStringRecord(_logManager, _bufferManager, record); Assert.AreEqual(LogRecordType.SetString, setBoolRecord.Type); Assert.AreEqual(0, setBoolRecord.Block.Id); Assert.AreEqual(0, setBoolRecord.Offset); Assert.AreEqual("default string", setBoolRecord.Value); Assert.AreEqual(6, setBoolRecord.TransactionNumber); }
public bool SetString(Block block, int offset, string value) { _concurrencyManager.ExclusiveLock(block); var buffer = _bufferList.GetBuffer(block); int lsn = _recoveryManager.SetString(buffer, offset, value); return(buffer.SetString(offset, value, _transactionNumber, lsn)); }
public void CanSetTempString() { var page = _fileManager.ResolvePage(); var block = new Block("temp" + RandomFilename, 0); page.Read(block); page.SetString(0, "default string"); page.Write(block); _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6); var buffer = _bufferManager.Pin(block); var lsn = _recoveryManager.SetString(buffer, 0, "string default"); Assert.AreEqual(-1, lsn); }