public void PageAllocationTest() { var db = new SimpleDatabase_Accessor("MMM", false); db.Initialize(); const int rowSize = 100; var tid = new Transaction(); var encoder = new UTF8Encoding(); db.CreateTable("Hotel", rowSize); var table = db.OpenTable("Hotel"); var keys = new string[table.PageTable.RecordIndices.Length]; var values = new string[table.PageTable.RecordIndices.Length]; for (int index = 0; index < table.PageTable.RecordIndices.Length; index++) { keys[index] = Guid.NewGuid().ToString(); values[index] = "VVVVVVVVVVVVVVVVVVVVV_" + index; } for (int index = 0; index < table.PageTable.RecordIndices.Length; index++) { db.InsertRecord(tid, table.Name, keys[index], new Row(rowSize) { Data = encoder.GetBytes(values[index]) }); } for (int index = 0; index < table.PageTable.RecordIndices.Length; index++) { var row = db.ReadRecord(tid, table.Name, keys[index]); Assert.AreEqual(values[index], row.DataString); } var rows = db.ReadAllRecords(null, "Hotel"); Assert.AreEqual(table.PageTable.RecordIndices.Length, rows.Count); }
public void PageAllocationTest() { var db = new SimpleDatabase_Accessor("MMM", false); db.Initialize(); const int rowSize = 100; var tid = new Transaction(); var encoder = new UTF8Encoding(); db.CreateTable("Hotel", rowSize); var table = db.OpenTable("Hotel"); var keys = new string[table.PageTable.RecordIndices.Length]; var values = new string[table.PageTable.RecordIndices.Length]; for (int index = 0; index < table.PageTable.RecordIndices.Length; index++) { keys[index] = Guid.NewGuid().ToString(); values[index] = "VVVVVVVVVVVVVVVVVVVVV_" + index; } for (int index = 0; index < table.PageTable.RecordIndices.Length; index++) { db.InsertRecord(tid, table.Name, keys[index], new Row(rowSize) { Data = encoder.GetBytes(values[index]) }); } for (int index = 0; index < table.PageTable.RecordIndices.Length; index++) { var row = db.ReadRecord(tid, table.Name, keys[index]); Assert.AreEqual(values[index], row.DataString); } var rows = db.ReadAllRecords(null, "Hotel"); Assert.AreEqual(table.PageTable.RecordIndices.Length, rows.Count); }