public DbSchema GetSchema(string tableName)
 {
     return(new DbSchema
     {
         TableName = tableName,
         Columns = _tableColumnExtractor.Extract(tableName),
         Indexes = _tableIndexExtractor.Extract(tableName)
     });
 }
Exemple #2
0
        public void Extract_ShouldReturn_CollectionOf_DbColumn()
        {
            var columns = new[]
            {
                new OleDbColumn
                {
                    Name       = "ID",
                    DataType   = DbType.Int64,
                    OleDbType  = OleDbType.BigInt,
                    IsNullable = false,
                    Position   = 1
                },
                new OleDbColumn
                {
                    Name       = "Username",
                    DataType   = DbType.String,
                    OleDbType  = OleDbType.VarWChar,
                    IsNullable = false,
                    Position   = 2
                }
            };
            var schema = TableColumnSchemaHelper.Build(columns);

            _connection
            .Setup(x => x.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, "test_1" }))
            .Returns(schema);

            var results = _extractor.Extract("test_1").ToArray();

            Assert.AreEqual(2, results.Length);

            for (var i = 0; i < columns.Length; i++)
            {
                Assert.AreEqual(columns[i].Name, results[i].Name);
                Assert.AreEqual(columns[i].DataType, results[i].DataType);
                Assert.AreEqual(columns[i].IsNullable, results[i].IsNullable);
                Assert.AreEqual(columns[i].Position, results[i].Position);
            }
        }