public void SetValue(string fieldName, Constant value) { var type = _schema.FieldType(fieldName); switch (type) { case FieldType.Bool: _recordFile.SetBool(fieldName, (value as Constant <bool>).Value); return; case FieldType.Byte: _recordFile.SetByte(fieldName, (value as Constant <byte>).Value); return; case FieldType.Integer: _recordFile.SetInt(fieldName, (value as Constant <int>).Value); return; case FieldType.Blob: _recordFile.SetBlob(fieldName, (value as Constant <byte[]>).Value); return; case FieldType.Date: _recordFile.SetDate(fieldName, (value as Constant <DateTime>).Value); return; } }
public void CanReadWrittenBoolRecord() { var tableFile = RandomFilename; var schema = new Schema(); schema.AddBoolField("field"); _tableInfo = new TableInfo(tableFile, schema); _recordFile = new RecordFile(_tableInfo, _transaction); _recordFile.MoveToRID(new RID(0, 0)); _recordFile.SetBool("field", true); _recordFile.Close(); _transaction.Commit(); var cm = new ConcurrencyManager(); var newTr = new Transaction(_dispatcher, _bufferManager, cm, _fileManager, _logManager); var rf = new RecordFile(_tableInfo, newTr); rf.MoveToRID(new RID(0, 0)); var value = rf.GetBool("field"); Assert.AreEqual(true, value); }
public void CanWriteBoolOnARecord() { var tableFile = RandomFilename; var schema = new Schema(); schema.AddBoolField("field"); _tableInfo = new TableInfo(tableFile, schema); _recordFile = new RecordFile(_tableInfo, _transaction); _recordFile.MoveToRID(new RID(0, 0)); _recordFile.SetBool("field", true); _recordFile.Close(); _transaction.Commit(); var block = new IO.Primitives.Block(tableFile + ".tbl", 0); var page = _fileManager.ResolvePage(block); page.Read(block); _ = page.GetBool(4, out var value); Assert.AreEqual(true, value); }