Esempio n. 1
0
        public void SqlWriterTest_CreateTableStatement()
        {
            // Arrange
            var jsonSettings = @"
            {
            ""importFiles"": 
                [
                    {
                        ""file"": ""..\\..\\..\\..\\TestCsv\\simpleComma.csv"",
                        ""batchSize"": 4,
                        ""forceCreateTable"": true
                                             }
                ]
            }";

            var importTasks = (List <ImportFileOptions>)CsvToSql.Configuration.ImportTasks.ReadTasks(log, jsonSettings);

            var sqlWriter = new SqlServerWriter(log, "");

            var headers = new List <string>()
            {
                "head1", "head2"
            };

            // Act
            sqlWriter.Init(importTasks.First(), headers);
            var tableDropSql   = sqlWriter.GetDropTableStatement();
            var tableCreateSql = sqlWriter.GetCreateTableStatement();

            // Assert
            Assert.IsTrue(sqlWriter != null);
            Assert.IsTrue(tableCreateSql.Contains("CREATE TABLE"));
            Assert.IsTrue(tableDropSql.Contains("DROP TABLE"));
            Assert.IsTrue(tableCreateSql.Contains("head1"));
            Assert.IsTrue(tableCreateSql.Contains("head2"));
        }