예제 #1
0
        public void TestTableData()
        {
            var columns = DatabaseObjectCreation.CreateTestTable(this.connectionType);

            DatabaseAssistant databaseAssistant = DatabaseAssistant.GetDatabaseAssistant(this.connectionType);

            try
            {
                using (var connection = databaseAssistant.CreateConnection(DatabaseHelpers.GetDefaultConnectionString(this.connectionType)))
                {
                    connection.Open();
                    Assert.IsTrue(databaseAssistant.GetTableNames(connection).Any(t => t.IndexOf("TestTable", StringComparison.InvariantCultureIgnoreCase) != -1));
                }
            }
            finally
            {
                DatabaseObjectCreation.RemoveTestTable(this.connectionType);
            }

            Assert.AreEqual(5, columns.Count);

            var column = columns[0];

            Assert.AreEqual("INTVALUE", column.Name.ToUpper());
            Assert.AreEqual(DatabaseModel.DataType.Int32, column.DataType);
            Assert.IsFalse(column.IsNullable);
            column = columns[1];
            Assert.AreEqual("DOUBLEVALUE", column.Name.ToUpper());
            Assert.AreEqual(DatabaseModel.DataType.Double, column.DataType);
            Assert.IsTrue(column.IsNullable);
            column = columns[2];
            Assert.AreEqual("STRINGVALUE", column.Name.ToUpper());
            Assert.AreEqual(DatabaseModel.DataType.String, column.DataType);
            Assert.IsTrue(column.IsNullable);
            column = columns[3];
            Assert.AreEqual("DATEVALUE", column.Name.ToUpper());
            Assert.AreEqual(this.connectionType == ConnectionType.OleDb ? DatabaseModel.DataType.String : DatabaseModel.DataType.Date,
                            column.DataType);
            Assert.IsTrue(column.IsNullable);
            column = columns[4];
            Assert.AreEqual("BYTESVALUE", column.Name.ToUpper());
            Assert.AreEqual(DatabaseModel.DataType.Binary, column.DataType);
            Assert.IsTrue(column.IsNullable);
        }