public void IntTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("IntTests").ToList(); Assert.AreEqual(1, rows[0].Field <int?>("A")); Assert.AreEqual(-125, rows[1].Field <int?>("A")); Assert.AreEqual(-129, rows[2].Field <int?>("A")); Assert.AreEqual(-130, rows[3].Field <int?>("A")); Assert.AreEqual(125, rows[4].Field <int?>("A")); Assert.AreEqual(130, rows[5].Field <int?>("A")); Assert.AreEqual(-32768, rows[6].Field <int?>("A")); Assert.AreEqual(32767, rows[7].Field <int?>("A")); Assert.AreEqual(null, rows[8].Field <int?>("A")); Assert.AreEqual(0, rows[9].Field <int?>("A")); Assert.AreEqual(32768, rows[10].Field <int?>("A")); Assert.AreEqual(8388607, rows[11].Field <int?>("A")); Assert.AreEqual(2147483647, rows[12].Field <int?>("A")); Assert.AreEqual(-8388608, rows[13].Field <int?>("A")); Assert.AreEqual(-8388609, rows[14].Field <int?>("A")); Assert.AreEqual(-2147483648, rows[15].Field <int?>("A")); }); }
public void BigintTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("BigintTests").ToList(); Assert.AreEqual(1, rows[0].Field<long?>("A")); Assert.AreEqual(-125, rows[1].Field<long?>("A")); Assert.AreEqual(-129, rows[2].Field<long?>("A")); Assert.AreEqual(-130, rows[3].Field<long?>("A")); Assert.AreEqual(125, rows[4].Field<long?>("A")); Assert.AreEqual(130, rows[5].Field<long?>("A")); Assert.AreEqual(-32768, rows[6].Field<long?>("A")); Assert.AreEqual(32767, rows[7].Field<long?>("A")); Assert.AreEqual(null, rows[8].Field<long?>("A")); Assert.AreEqual(0, rows[9].Field<long?>("A")); Assert.AreEqual(32768, rows[10].Field<long?>("A")); Assert.AreEqual(8388607, rows[11].Field<long?>("A")); Assert.AreEqual(2147483647, rows[12].Field<long?>("A")); Assert.AreEqual(-8388608, rows[13].Field<long?>("A")); Assert.AreEqual(-8388609, rows[14].Field<long?>("A")); Assert.AreEqual(-2147483648, rows[15].Field<long?>("A")); Assert.AreEqual(9223372036854775807, rows[16].Field<long?>("A")); Assert.AreEqual(36028797018963967, rows[17].Field<long?>("A")); Assert.AreEqual(140737488355327, rows[18].Field<long?>("A")); Assert.AreEqual(549755813887, rows[19].Field<long?>("A")); Assert.AreEqual(2147483648, rows[20].Field<long?>("A")); Assert.AreEqual(-9223372036854775808, rows[21].Field<long?>("A")); Assert.AreEqual(-36028797018963967, rows[22].Field<long?>("A")); Assert.AreEqual(-140737488355327, rows[23].Field<long?>("A")); Assert.AreEqual(-549755813887, rows[24].Field<long?>("A")); Assert.AreEqual(-2147483648, rows[25].Field<long?>("A")); }); }
public void BigintTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("BigintTests").ToList(); Assert.AreEqual(1, rows[0].Field <long?>("A")); Assert.AreEqual(-125, rows[1].Field <long?>("A")); Assert.AreEqual(-129, rows[2].Field <long?>("A")); Assert.AreEqual(-130, rows[3].Field <long?>("A")); Assert.AreEqual(125, rows[4].Field <long?>("A")); Assert.AreEqual(130, rows[5].Field <long?>("A")); Assert.AreEqual(-32768, rows[6].Field <long?>("A")); Assert.AreEqual(32767, rows[7].Field <long?>("A")); Assert.AreEqual(null, rows[8].Field <long?>("A")); Assert.AreEqual(0, rows[9].Field <long?>("A")); Assert.AreEqual(32768, rows[10].Field <long?>("A")); Assert.AreEqual(8388607, rows[11].Field <long?>("A")); Assert.AreEqual(2147483647, rows[12].Field <long?>("A")); Assert.AreEqual(-8388608, rows[13].Field <long?>("A")); Assert.AreEqual(-8388609, rows[14].Field <long?>("A")); Assert.AreEqual(-2147483648, rows[15].Field <long?>("A")); Assert.AreEqual(9223372036854775807, rows[16].Field <long?>("A")); Assert.AreEqual(36028797018963967, rows[17].Field <long?>("A")); Assert.AreEqual(140737488355327, rows[18].Field <long?>("A")); Assert.AreEqual(549755813887, rows[19].Field <long?>("A")); Assert.AreEqual(2147483648, rows[20].Field <long?>("A")); Assert.AreEqual(-9223372036854775808, rows[21].Field <long?>("A")); Assert.AreEqual(-36028797018963967, rows[22].Field <long?>("A")); Assert.AreEqual(-140737488355327, rows[23].Field <long?>("A")); Assert.AreEqual(-549755813887, rows[24].Field <long?>("A")); Assert.AreEqual(-2147483648, rows[25].Field <long?>("A")); }); }
public void DataScanner_Readstring() { var addrBase = Address.Ptr32(0x00123000); var mem = new MemoryArea(addrBase, new byte[0x1000]); var segmap = new SegmentMap(addrBase, new ImageSegment("code", mem, AccessMode.ReadWrite)); Given_Architecture(); var program = new Program( segmap, arch.Object, new Mock <IPlatform>().Object); var sr = new ScanResults(); var addr = Address.Ptr32(0x00123400); Given_String(mem, addr, "Hello"); var dsc = new DataScanner(program, sr, new FakeDecompilerEventListener()); dsc.EnqueueUserGlobalData(addr, StringType.NullTerminated(PrimitiveType.Char), "sHello"); dsc.ProcessQueue(); var item = program.ImageMap.Items[addr]; Assert.AreEqual(6, item.Size); }
public async Task Kill() { // THe user to check for priviliges IGuildUser user = Context.User as IGuildUser; // If the user is an admin Log Sonnie off and kill the program if (user.IsAdmin()) { Debug.Log.Message("AdminCommands - Trying to log off"); // Get the application client DiscordSocketClient client = Context.Client as DiscordSocketClient; await Context.Channel.SendMessageAsync("Jamen vi ses så!"); // Save the list of users to the STB.UP file DataScanner <User> scanner = new DataScanner <User> (@"\Data\Users\STB.UP"); await scanner.WriteToFile(UserManager.GetUserList()); await client.LogoutAsync(); // Kill the program Environment.Exit(-1); } await Context.Channel.SendMessageAsync("Ups... Du er vidst ikke admin"); }
/// <summary> /// Loads the database for this instance. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public override bool LoadSchema(string fileName) { Database = new Database(fileName); TableNodes = new List <DatabaseNode>(); var scanner = new DataScanner(Database); var tables = Database.Dmvs.Tables; foreach (var table in tables.Where(t => !t.IsMSShipped).OrderBy(t => t.Name)) { var rows = scanner.ScanTable(table.Name); var tableItem = new DatabaseNode(); tableItem.Name = table.Name; var rowData = rows.FirstOrDefault(); if (rowData != null) { foreach (var column in rowData.Columns) { var childItem = new DatabaseNode(); childItem.Name = column.Name; childItem.NodeType = Extensions.GetSQLType(column.Type); childItem.Value = rowData[column] ?? DBNull.Value; childItem.Table.Add(tableItem); tableItem.Columns.Add(childItem); } } TableNodes.Add(tableItem); } return(TableNodes.Count() > 0 ? true : false); }
public async Task PlanEvent(string _name, string _timeSpan = null, string _description = null, string _otherInformation = null, string _prompt = null) { // Return a list with all currently stored events if (_name == "?") { if (EventManager.Events.Count != 0 && EventManager.Events != null) { string eventList = string.Empty; foreach (Event item in EventManager.Events) { eventList += item.Print(); } await Context.Message.Author.SendMessageAsync(eventList); return; } await Context.Channel.SendMessageAsync("Der er ingen events!"); return; } IGuildUser user = Context.User as IGuildUser; if (user.IsAdmin()) { // Cancel an event if (_name.ToLower() == "annuller") { string eventName = _timeSpan.ToLower(); EventManager.Events.Remove(EventManager.Events.Find(_event => _event.Name.ToLower() == eventName)); DataScanner <Event> scanner2 = new DataScanner <Event> (@"\Data\Events\STB.EP"); await scanner2.WriteToFile(EventManager.Events); await Context.Channel.SendMessageAsync("Oh... Det event er annulleret"); return; } // Extract the requered data from the passed string string [] rawDates = _timeSpan.Split('-'); DateTime startDate = new DateTime().Parse(rawDates [0]); DateTime endDate = new DateTime().Parse(rawDates [1]); DateTime prompt = new DateTime().Parse(_prompt); // Search for the auther of this event in the stored users and use his/her real name. If not found use the discord username instead string auther = (UserManager.SearchUserByID(Context.Message.Author.Id).Name ?? Context.Message.Author.Username); Event newEvent = new Event(_name, startDate, endDate, _description, _otherInformation, prompt, auther); EventManager.Events.Add(newEvent); // Save data to file DataScanner <Event> scanner = new DataScanner <Event> (@"\Data\Events\STB.EP"); await scanner.WriteToFile(EventManager.Events); await Context.Channel.SendMessageAsync($"Nyt event. Spændende!"); } }
/// <summary> /// Loads the database for this instance. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public override bool LoadSchema(string fileName) { Database = new Database(fileName); DataNodes = new List <DataNode>(); var scanner = new DataScanner(Database); var tables = Database.Dmvs.Tables.Where(t => !t.IsMSShipped) .OrderBy(t => t.Name).ToList(); foreach (var table in tables) { // ignore tables that can't be read successfully Row rowData = null; try { rowData = scanner.ScanTable(table.Name).FirstOrDefault(); } catch { LogException(string.Empty, $"Could not get data preview for {table.Name}. A blank record will preview instead."); } var tableItem = new DataNode { Name = table.Name }; // get the table schema foreach (var column in Database.Dmvs.Columns.Where(x => x.ObjectID == table.ObjectID)) { var childItem = new DataNode { Name = column.Name, NodeType = typeof(string), Value = DBNull.Value }; // try to read data for this table if (rowData != null) { var dataColumn = rowData.Columns.FirstOrDefault(d => d.Name == column.Name); if (dataColumn != null) { childItem.NodeType = GetSQLType(dataColumn.Type) ?? typeof(string); childItem.Value = rowData[dataColumn] ?? DBNull.Value; } } childItem.Parent.Add(tableItem); tableItem.Children.Add(childItem); } DataNodes.Add(tableItem); } return(DataNodes.Count > 0 ? true : false); }
public void NVarcharMax33(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("NVarcharMaxTest33").ToList(); Assert.AreEqual("".PadLeft(33, '\u040A'), rows[0].Field<string>("A")); }); }
public void NText4020(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("NTextTest4020").ToList(); Assert.AreEqual("".PadLeft(4020, '\u040A'), rows[0].Field<string>("A")); }); }
public void VarcharMax40201(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarcharMaxTest40201").ToList(); Assert.AreEqual("".PadLeft(40201, 'A'), rows[0].Field <string>("A")); }); }
public void NTextEmpty(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("NTextTestEmpty").ToList(); Assert.AreEqual("", rows[0].Field <string>("A")); }); }
public void VarBinaryNull(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarBinaryTestNull").ToList(); Assert.AreEqual(null, rows[0].Field <string>("A")); }); }
public void VarcharBlobInlineRoot(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarcharBlobInlineRoot").ToList(); Assert.AreEqual("".PadLeft(25000, 'A'), rows[0].Field <string>("A")); }); }
public void FGSpecificClusteredAllocation(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("FGSpecificClustered").ToList(); Assert.AreEqual(100, rows.Count); }); }
public void Text65(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("TextTest65").ToList(); Assert.AreEqual("".PadLeft(65, 'A'), rows[0].Field<string>("A")); }); }
public void VarBinaryEmpty(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarBinaryTestEmpty").ToList(); Assert.AreEqual("", rows[0].Field <byte[]>("A")); }); }
public void NText20101(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("NTextTest20101").ToList(); Assert.AreEqual("".PadLeft(20101, '\u040A'), rows[0].Field <string>("A")); }); }
public void VarBinary40201(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarBinaryTest40201").ToList(); Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(40201, 'A')), rows[0].Field <byte[]>("A")); }); }
public void Image65(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("ImageTest65").ToList(); Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(65, 'A')), rows[0].Field<byte[]>("A")); }); }
public void RoundRobinHeapAllocation(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("RoundRobinHeap").ToList(); Assert.AreEqual(100, rows.Count); }); }
public void RoundRobinHeapAllocation(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("RoundRobinHeap").ToList(); Assert.AreEqual(100, rows.Count); }); }
public void VarcharBlobInlineRoot(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarcharBlobInlineRoot").ToList(); Assert.AreEqual("".PadLeft(25000, 'A'), rows[0].Field<string>("A")); }); }
public void VarcharMax8040(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarcharMaxTest8040").ToList(); Assert.AreEqual("".PadLeft(8040, 'A'), rows[0].Field<string>("A")); }); }
public void Nulls(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("Nulls").ToList(); Assert.AreEqual(null, rows[0].Field <decimal?>("A")); }); }
public void Image8040(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("ImageTest8040").ToList(); Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(8040, 'A')), rows[0].Field <byte[]>("A")); }); }
public void Text8040(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("TextTest8040").ToList(); Assert.AreEqual("".PadLeft(8040, 'A'), rows[0].Field <string>("A")); }); }
public void NVarcharMax33(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("NVarcharMaxTest33").ToList(); Assert.AreEqual("".PadLeft(33, '\u040A'), rows[0].Field <string>("A")); }); }
public void EnabledAfterInserting(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("EnabledAfterInserting").ToList(); Assert.AreEqual(1234.45m, rows[0].Field <decimal>("A")); }); }
public void VarBinary8040(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("VarBinaryTest8040").ToList(); Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(8040, 'A')), rows[0].Field<byte[]>("A")); }); }
public void FGSpecificClusteredAllocation(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("FGSpecificClustered").ToList(); Assert.AreEqual(100, rows.Count); }); }
public IEnumerable<Row> ScanIndex(string tableName, string indexName) { // Get table var table = Database.Dmvs.Objects .Where(x => x.Name == tableName && (x.Type == ObjectType.USER_TABLE || x.Type == ObjectType.SYSTEM_TABLE)) .SingleOrDefault(); if (table == null) throw new UnknownTableException(tableName); // Get index var index = Database.Dmvs.Indexes .Where(i => i.ObjectID == table.ObjectID && i.Name == indexName) .SingleOrDefault(); if (index == null) throw new UnknownIndexException(tableName, indexName); // Depending on index type, scan accordingly switch(index.Type) { case IndexType.Heap: case IndexType.Clustered: // For both heaps and clustered tables we delegate the responsibility to a DataScanner var scanner = new DataScanner(Database); return scanner.ScanTable(tableName); case IndexType.Nonclustered: // Get the schema for the index var schema = MetaData.GetEmptyIndexRow(tableName, indexName); // Get rowset for the index var tableRowset = Database.Dmvs.SystemInternalsPartitions .Where(x => x.ObjectID == table.ObjectID && x.IndexID == index.IndexID) .FirstOrDefault(); if (tableRowset == null) throw new Exception("Index has no rowset"); // Get allocation unit for in-row data var allocUnit = Database.Dmvs.SystemInternalsAllocationUnits .Where(au => au.ContainerID == tableRowset.PartitionID && au.Type == (byte)AllocationUnitType.IN_ROW_DATA) .SingleOrDefault(); if (allocUnit == null) throw new ArgumentException("Table has no allocation unit."); // Scan the linked list of nonclustered index pages // TODO: Support compressed indexes return ScanLinkedNonclusteredIndexPages(allocUnit.FirstPage, schema, CompressionContext.NoCompression); default: throw new ArgumentException("Unsupported index type '" + index.Type + "'"); } }
public void ScanAllNullSparse(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("ScanAllNullSparse").ToList(); Assert.AreEqual(null, rows[0].Field<int?>("A")); Assert.AreEqual(null, rows[0].Field<int?>("B")); }); }
public void UniqueidentifierTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("UniqueidentifierTests").ToList(); Assert.AreEqual(null, rows[0].Field <Guid?>("A")); Assert.AreEqual(new Guid("92F9A6D1-E99E-49AC-9D85-996F4BC08B20"), rows[1].Field <Guid?>("A")); }); }
public void ScanAllNullSparse(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("ScanAllNullSparse").ToList(); Assert.AreEqual(null, rows[0].Field <int?>("A")); Assert.AreEqual(null, rows[0].Field <int?>("B")); }); }
public void BinaryTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("BinaryTest").ToList(); Assert.AreEqual(null, rows[0].Field<byte[]>("A")); Assert.AreEqual(TestHelper.GetBytesFromByteString("25FF2500000000000000"), rows[1].Field<byte[]>("A")); Assert.AreEqual(TestHelper.GetBytesFromByteString("01020304050607080910"), rows[2].Field<byte[]>("A")); }); }
public void RowOverflowPointer(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("RowOverflowPointer").ToList(); Assert.AreEqual(1, rows.Count); Assert.AreEqual("".PadLeft(5000, 'a'), rows[0]["A"]); Assert.AreEqual("".PadLeft(5000, 'b'), rows[0]["B"]); }); }
public void RowOverflowPointer(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("RowOverflowPointer").ToList(); Assert.AreEqual(1, rows.Count); Assert.AreEqual("".PadLeft(5000, 'a'), rows[0]["A"]); Assert.AreEqual("".PadLeft(5000, 'b'), rows[0]["B"]); }); }
public void MultipleLongDataColumns(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("MultipleLongDataColumns").ToList(); Assert.AreEqual(TestHelper.GetBytesFromByteString("01020304050607080910"), rows[0].Field<byte[]>("A")); Assert.AreEqual(TestHelper.GetBytesFromByteString("09080706050403020100"), rows[0].Field<byte[]>("B")); Assert.AreEqual(TestHelper.GetBytesFromByteString("112233445566778899AA"), rows[0].Field<byte[]>("C")); }); }
public void Garbage2(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("Garbage2").ToList(); Assert.AreEqual(5, rows[0].Field<int?>("A")); Assert.AreEqual(2, rows[0].Field<int?>("B")); Assert.AreEqual(null, rows[0].Field<string>("C")); }); }
public void MultipleLongDataColumns(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("MultipleLongDataColumns").ToList(); Assert.AreEqual(TestHelper.GetBytesFromByteString("01020304050607080910"), rows[0].Field <byte[]>("A")); Assert.AreEqual(TestHelper.GetBytesFromByteString("09080706050403020100"), rows[0].Field <byte[]>("B")); Assert.AreEqual(TestHelper.GetBytesFromByteString("112233445566778899AA"), rows[0].Field <byte[]>("C")); }); }
public void MultipleShortDataColumns(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("MultipleShortDataColumns").ToList(); Assert.AreEqual(1, rows[0].Field <byte>("A")); Assert.AreEqual(2, rows[0].Field <byte>("B")); Assert.AreEqual(3, rows[0].Field <byte>("C")); }); }
public void Garbage2(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("Garbage2").ToList(); Assert.AreEqual(5, rows[0].Field <int?>("A")); Assert.AreEqual(2, rows[0].Field <int?>("B")); Assert.AreEqual(null, rows[0].Field <string>("C")); }); }
public void MultipleShortDataColumns(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("MultipleShortDataColumns").ToList(); Assert.AreEqual(1, rows[0].Field<byte>("A")); Assert.AreEqual(2, rows[0].Field<byte>("B")); Assert.AreEqual(3, rows[0].Field<byte>("C")); }); }
public void ImageTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("ImageTests").ToList(); Assert.AreEqual(null, rows[0].Field <byte[]>("A")); Assert.AreEqual(TestHelper.GetBytesFromByteString("25FF25"), rows[1].Field <byte[]>("A")); Assert.AreEqual(TestHelper.GetBytesFromByteString("01020304050607080910"), rows[2].Field <byte[]>("A")); }); }
public void TextTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("TextTests").ToList(); Assert.AreEqual(null, rows[0].Field <string>("A")); Assert.AreEqual("a", rows[1].Field <string>("A")); Assert.AreEqual("1234567890", rows[2].Field <string>("A")); }); }
public void DifferingRecordFormats(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("DifferingRecordFormats").ToList(); Assert.AreEqual(5, rows[0].Field<int?>("A")); Assert.AreEqual(2, rows[0].Field<int?>("B")); Assert.AreEqual(6, rows[1].Field<int?>("A")); Assert.AreEqual(null, rows[1].Field<int?>("B")); }); }
private void loadTable(string table) { try { var scanner = new DataScanner(db); var rows = scanner.ScanTable(table).Take(1000); showRows(rows); } catch (Exception ex) { logException(ex); } }
public void HeapForwardedRecord(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("HeapForwardedRecord").ToList(); Assert.AreEqual(25, rows[0].Field<int>("A")); Assert.AreEqual("".PadLeft(5000, 'A'), rows[0].Field<string>("B")); Assert.AreEqual(28, rows[1].Field<int>("A")); Assert.AreEqual("".PadLeft(4000, 'B'), rows[1].Field<string>("B")); }); }
public void ScanRecordWithoutSparseVector(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("ScanRecordWithoutSparseVector").ToList(); Assert.AreEqual(null, rows[0].Field<int?>("A")); Assert.AreEqual("xyz", rows[0].Field<string>("B")); Assert.AreEqual(null, rows[1].Field<int?>("A")); Assert.AreEqual(null, rows[1].Field<string>("B")); }); }
public void IgnoreDroppedColumnData(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("IgnoreDroppedColumnData").ToList(); Assert.AreEqual(1, rows.Count); Assert.AreEqual(1, rows[0].Field<int>("A")); Assert.AreEqual(27, rows[0].Field<int>("B")); Assert.AreEqual("A", rows[0].Field<string>("C")); Assert.AreEqual(3, rows[0].Field<int>("D")); }); }
public void ScanUniqueClusteredTable(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("UniqueClusteredTable").ToList(); Assert.AreEqual(112, rows[0].Field<int>("Num1")); Assert.AreEqual("Doe", rows[0].Field<string>("Name")); Assert.AreEqual(382, rows[1].Field<int>("Num1")); Assert.AreEqual("John", rows[1].Field<string>("Name")); }); }
public void DecimalTest(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("DecimalTest").ToList(); Assert.AreEqual(12345m, rows[0].Field<decimal>("A")); Assert.AreEqual(39201.230m, rows[0].Field<decimal>("B")); Assert.AreEqual(-4892384.382090m, rows[0].Field<decimal>("C")); Assert.AreEqual(1328783742987.29m, rows[0].Field<decimal>("D")); Assert.AreEqual(2940382040198493029.235m, rows[0].Field<decimal>("E")); }); }
public void SmallDatetimeTest(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("SmallDatetimeTest").ToList(); Assert.AreEqual(new DateTime(2012, 08, 07, 12, 23, 00), rows[0].Field<DateTime>("A")); Assert.AreEqual(new DateTime(2011, 02, 23, 01, 02, 00), rows[0].Field<DateTime>("B")); Assert.AreEqual(new DateTime(1900, 01, 01, 00, 00, 00), rows[0].Field<DateTime>("C")); Assert.AreEqual(new DateTime(1900, 01, 01, 00, 01, 00), rows[0].Field<DateTime>("D")); Assert.AreEqual(new DateTime(2079, 06, 06, 23, 59, 00), rows[0].Field<DateTime>("E")); Assert.AreEqual(new DateTime(2079, 06, 06, 23, 58, 00), rows[0].Field<DateTime>("F")); }); }
public void MoneyTest(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("MoneyTest").ToList(); Assert.AreEqual(123.4568m, rows[0].Field<decimal>("A")); Assert.AreEqual(-123.4568m, rows[1].Field<decimal>("A")); Assert.AreEqual(123456789.0123m, rows[2].Field<decimal>("A")); Assert.AreEqual(-123456789.0123m, rows[3].Field<decimal>("A")); Assert.AreEqual(-922337203685477.5808m, rows[4].Field<decimal>("A")); Assert.AreEqual(922337203685477.5807m, rows[5].Field<decimal>("A")); }); }
public void SmallMoneyTest(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("SmallMoneyTest").ToList(); Assert.AreEqual(123.4568m, rows[0].Field<decimal>("A")); Assert.AreEqual(-123.4568m, rows[1].Field<decimal>("A")); Assert.AreEqual(123456.0123m, rows[2].Field<decimal>("A")); Assert.AreEqual(-123456.0123m, rows[3].Field<decimal>("A")); Assert.AreEqual(-214748.3648m, rows[4].Field<decimal>("A")); Assert.AreEqual(214748.3647m, rows[5].Field<decimal>("A")); }); }
public void UniquifierTest(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("UniquifierTest").ToList(); Assert.AreEqual(1, rows[0].Field<int?>("A")); Assert.AreEqual(0, rows[0].Field<int?>(DataColumn.Uniquifier)); Assert.AreEqual(1, rows[1].Field<int?>("A")); Assert.AreEqual(1, rows[1].Field<int?>(DataColumn.Uniquifier)); Assert.AreEqual(1, rows[2].Field<int?>("A")); Assert.AreEqual(2, rows[2].Field<int?>(DataColumn.Uniquifier)); }); }
internal BaseTableData(Database db) { this.db = db; scanner = new DataScanner(db); // These are the very core base tables that we'll need to dynamically construct the schema of any other // required tables. By aggresively parsing these, we can do lazy loading of the rest. parseSysallocunits(); parseSysrowsets(); parseSyscolpars(); parseSysobjects(); parseSysscalartypes(); parseSysrscols(); parseSyssingleobjrefs(); }
public void ScanNonSparseInts(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("ScanNonSparseInts").ToList(); Assert.AreEqual(123, rows[0].Field<int?>("A")); Assert.AreEqual(null, rows[0].Field<int?>("B")); Assert.AreEqual(null, rows[0].Field<int?>("C")); Assert.AreEqual(127, rows[0].Field<int?>("D")); Assert.AreEqual(null, rows[1].Field<int?>("A")); Assert.AreEqual(null, rows[1].Field<int?>("B")); Assert.AreEqual(123982, rows[1].Field<int?>("C")); Assert.AreEqual(null, rows[1].Field<int?>("D")); }); }
public void BitTests(DatabaseVersion version) { RunDatabaseTest(version, db => { var scanner = new DataScanner(db); var rows = scanner.ScanTable("BitTests").ToList(); Assert.AreEqual(null, rows[0].Field<bool?>("A")); Assert.AreEqual(true, rows[1].Field<bool?>("A")); Assert.AreEqual(true, rows[2].Field<bool?>("A")); Assert.AreEqual(false, rows[3].Field<bool?>("A")); Assert.AreEqual(true, rows[4].Field<bool?>("A")); Assert.AreEqual(false, rows[5].Field<bool?>("A")); Assert.AreEqual(false, rows[6].Field<bool?>("A")); Assert.AreEqual(null, rows[7].Field<bool?>("A")); Assert.AreEqual(true, rows[8].Field<bool?>("A")); }); }