Ejemplo n.º 1
0
        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"));
            });
        }
Ejemplo n.º 2
0
        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"));
            });
        }
Ejemplo n.º 3
0
        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"));
            });
        }
Ejemplo n.º 4
0
        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"));
            });
        }
Ejemplo n.º 5
0
        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"));
            });
        }
Ejemplo n.º 6
0
        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"));
            });
        }
Ejemplo n.º 7
0
        public void Text8041(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("TextTest8041").ToList();

                Assert.AreEqual("".PadLeft(8041, 'A'), rows[0].Field <string>("A"));
            });
        }
Ejemplo n.º 8
0
        public void FGSpecificClusteredAllocation(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows = scanner.ScanTable("FGSpecificClustered").ToList();

                Assert.AreEqual(100, rows.Count);
            });
        }
Ejemplo n.º 9
0
        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"));
            });
        }
Ejemplo n.º 10
0
        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"));
            });
        }
Ejemplo n.º 11
0
        public void FGSpecificClusteredAllocation(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("FGSpecificClustered").ToList();

                Assert.AreEqual(100, rows.Count);
            });
        }
Ejemplo n.º 12
0
        public void NVarcharMax20100(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("NVarcharMaxTest20100").ToList();

                Assert.AreEqual("".PadLeft(20100, '\u040A'), rows[0].Field <string>("A"));
            });
        }
Ejemplo n.º 13
0
        public void Image40201(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("ImageTest40201").ToList();

                Assert.AreEqual(Encoding.UTF7.GetBytes("".PadLeft(40201, 'A')), rows[0].Field <byte[]>("A"));
            });
        }
Ejemplo n.º 14
0
        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"));
            });
        }
Ejemplo n.º 15
0
        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"));
            });
        }
Ejemplo n.º 16
0
        public void VarcharMaxNull(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("VarcharMaxTestNull").ToList();

                Assert.AreEqual(null, rows[0].Field <string>("A"));
            });
        }
Ejemplo n.º 17
0
        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"));
            });
        }
Ejemplo n.º 18
0
        public void RoundRobinHeapAllocation(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows = scanner.ScanTable("RoundRobinHeap").ToList();

                Assert.AreEqual(100, rows.Count);
            });
        }
Ejemplo n.º 19
0
        public void RoundRobinHeapAllocation(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("RoundRobinHeap").ToList();

                Assert.AreEqual(100, rows.Count);
            });
        }
Ejemplo n.º 20
0
        /// <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,
                        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);
                            childItem.Value    = rowData[dataColumn] ?? DBNull.Value;
                        }
                    }

                    childItem.Parent.Add(tableItem);
                    tableItem.Children.Add(childItem);
                }

                DataNodes.Add(tableItem);
            }

            return(DataNodes.Count > 0 ? true : false);
        }
Ejemplo n.º 21
0
        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 + "'");
            }
        }
Ejemplo n.º 22
0
        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"));
            });
        }
Ejemplo n.º 23
0
        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"));
            });
        }
Ejemplo n.º 24
0
        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"));
            });
        }
Ejemplo n.º 25
0
        public void VarcharOverflow(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("VarcharOverflow").ToList();

                Assert.AreEqual("".PadLeft(5000, 'A'), rows[0].Field <string>("A"));
                Assert.AreEqual("".PadLeft(5000, 'B'), rows[0].Field <string>("B"));
            });
        }
Ejemplo n.º 26
0
        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"));
            });
        }
Ejemplo n.º 27
0
        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"));
            });
        }
Ejemplo n.º 28
0
        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"));
            });
        }
Ejemplo n.º 29
0
        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"));
            });
        }
Ejemplo n.º 30
0
        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"));
            });
        }
Ejemplo n.º 31
0
        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"));
            });
        }
Ejemplo n.º 32
0
        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"));
            });
        }
Ejemplo n.º 33
0
        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"));
            });
        }
Ejemplo n.º 34
0
        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"));
            });
        }
Ejemplo n.º 35
0
        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"]);
            });
        }
Ejemplo n.º 36
0
        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"]);
            });
        }
Ejemplo n.º 37
0
        public void TruncatedZeroes(DatabaseVersion version)
        {
            // 4398046511104 = 0b1000000000000000000000000000000000000000000
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows    = scanner.ScanTable("TruncatedZeroes").ToList();

                Assert.AreEqual(4398046511104m, rows[0].Field <decimal>("A"));
                Assert.AreEqual(4398046511104m, rows[0].Field <decimal>("B"));
                Assert.AreEqual(4398046511104m, rows[0].Field <decimal>("C"));
            });
        }
Ejemplo n.º 38
0
 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);
     }
 }
Ejemplo n.º 39
0
        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"));
            });
        }
Ejemplo n.º 40
0
        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"));
            });
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Loads the table data.
        /// </summary>
        /// <param name="db">The database.</param>
        /// <param name="allowedColumns">The allowed columns.</param>
        private void LoadTableData(Database db)
        {
            if (DataLoaded)
            {
                // No need to reload the data.
                return;
            }
            DataLoaded = true;

            var allowedColumns = F1SqlSchemaDefiniton.Columns[Name].Select(n => n.ToLower()).ToList();
            var scanner        = new DataScanner(db);
            var rows           = scanner.ScanTable(Name);

            _data = CreateDataTable();

            foreach (var row in rows)
            {
                bool addRow = false;
                var  dr     = _data.NewRow();
                foreach (var col in row.Columns)
                {
                    if (allowedColumns.Contains(col.Name.ToLower()))
                    {
                        object value = row[col];
                        if (value == null)
                        {
                            value = DBNull.Value;
                        }
                        else
                        {
                            addRow = true;
                        }
                        dr[col.Name] = value;
                    }
                }
                if (addRow)
                {
                    /*
                     * 8/10/2020 - Shaun
                     * This is an awkward workaround that seems to be necessary because OrcaMDF
                     * is reading some empty rows into the data for some unknown reason, which
                     * then causes problems when you read the data and expect values to be
                     * present (i.e., null values in non-nullable columns).  These empty rows
                     * do NOT show up if you attach the database to SQL server.
                     *
                     * */

                    _data.Rows.Add(dr);
                }
            }
        }
Ejemplo n.º 42
0
        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"));
            });
        }
Ejemplo n.º 43
0
        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"));
            });
        }
Ejemplo n.º 44
0
        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"));
            });
        }
Ejemplo n.º 45
0
        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"));
            });
        }
Ejemplo n.º 46
0
        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"));
            });
        }
Ejemplo n.º 47
0
        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"));
            });
        }
Ejemplo n.º 48
0
        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"));
            });
        }
Ejemplo n.º 49
0
        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"));
            });
        }
Ejemplo n.º 50
0
        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"));
            });
        }
Ejemplo n.º 51
0
        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"));
            });
        }
Ejemplo n.º 52
0
        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"));
            });
        }
Ejemplo n.º 53
0
        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"));
            });
        }
Ejemplo n.º 54
0
        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"));
            });
        }
Ejemplo n.º 55
0
        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"));
            });
        }
Ejemplo n.º 56
0
        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"));
            });
        }
Ejemplo n.º 57
0
        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));
            });
        }
Ejemplo n.º 58
0
        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"));
            });
        }
Ejemplo n.º 59
0
        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"));
            });
        }
Ejemplo n.º 60
0
        public void ScanSparseColumns(DatabaseVersion version)
        {
            RunDatabaseTest(version, db =>
            {
                var scanner = new DataScanner(db);
                var rows = scanner.ScanTable("ScanSparseColumns").ToList();

                Assert.AreEqual(null, rows[0].Field<int?>("A"));
                Assert.AreEqual("Mark", rows[0].Field<string>("B"));
                Assert.AreEqual(3, rows[0].Field<long?>("C"));
                Assert.AreEqual(null, rows[0].Field<byte?>("D"));
                Assert.AreEqual(1234, rows[0].Field<int?>("E"));

                Assert.AreEqual(45, rows[1].Field<int?>("A"));
                Assert.AreEqual(null, rows[1].Field<string>("B"));
                Assert.AreEqual(null, rows[1].Field<long?>("C"));
                Assert.AreEqual(243, rows[1].Field<byte?>("D"));
                Assert.AreEqual(null, rows[1].Field<int?>("E"));
            });
        }