public void WriteDataTable()
        {
            var dataTable = new DataTable
            {
                TableName = "DataTable",
                Locale    = CultureInfo.InvariantCulture
            };

            dataTable.Columns.Add("ID", typeof(int));
            dataTable.Columns.Add("Text", typeof(string));
            for (int i = 0; i < 100; i++)
            {
                var row = dataTable.NewRow();
                row["ID"]   = i;
                row["Text"] = i.ToString(CultureInfo.CurrentCulture);
                dataTable.Rows.Add(row);
            }
            var writeFile = new CsvFile
            {
                ID       = "Test.txt",
                FileName = Path.Combine(m_ApplicationDirectory, "Test.txt")
            };
            var writer = new CsvFileWriter(writeFile, CancellationToken.None);

            writer.WriteDataTable(dataTable);

            Assert.IsTrue(File.Exists(writeFile.FileName));
        }
        public void WriteFileLocked()
        {
            var dataTable = new DataTable
            {
                TableName = "DataTable",
                Locale    = CultureInfo.InvariantCulture
            };

            dataTable.Columns.Add("ID", typeof(int));
            dataTable.Columns.Add("Text", typeof(string));
            for (int i = 0; i < 5; i++)
            {
                var row = dataTable.NewRow();
                row["ID"]   = i;
                row["Text"] = i.ToString(CultureInfo.InvariantCulture);
                dataTable.Rows.Add(row);
            }
            var writeFile = new CsvFile
            {
                ID         = "Test.txt",
                FileName   = Path.Combine(m_ApplicationDirectory, "WriteFileLocked.txt"),
                InOverview = false
            };

            FileSystemUtils.FileDelete(writeFile.FileName);
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(writeFile.FileName))
            {
                file.WriteLine("Hello");

                var writer = new CsvFileWriter(writeFile, CancellationToken.None);
                writer.WriteDataTable(dataTable);

                Assert.IsTrue(!string.IsNullOrEmpty(writer.ErrorMessage));
                file.WriteLine("World");
            }
            FileSystemUtils.FileDelete(writeFile.FileName);
        }