Ejemplo n.º 1
0
        public void WriteAllFormats()
        {
            var pd = new MockProcessDisplay();

            var writeFile = new CsvFile
            {
                ID       = "Write",
                FileName = Path.Combine(m_ApplicationDirectory, "BasicCSVOut2.txt")
            };

            FileSystemUtils.FileDelete(writeFile.FileName);
            var setting = Helper.ReaderGetAllFormats(ApplicationSetting.ToolSetting);

            mimicReader.AddSetting(setting);
            writeFile.SqlStatement = setting.ID;

            writeFile.FileFormat.FieldDelimiter = "|";
            var cf = writeFile.ColumnAdd(new Column {
                Name = "DateTime", DataType = DataType.DateTime
            });

            cf.DateFormat     = "yyyyMMdd";
            cf.TimePartFormat = @"hh:mm";
            cf.TimePart       = "Time";
            var writer = new CsvFileWriter(writeFile, CancellationToken.None);

            writer.Progress += pd.SetProcess;
            var res = writer.Write();

            Assert.IsTrue(FileSystemUtils.FileExists(writeFile.FileName));
            Assert.AreEqual(1065, res, "Records");
        }
Ejemplo n.º 2
0
        public async Task TimeZoneConversionsAsync()
        {
            var pd = new MockProcessDisplay();

            var writeFile = (CsvFile)m_WriteFile.Clone();

            writeFile.FileName = UnitTestInitializeCsv.GetTestPath("BasicCSVOut2tzc.txt");

            FileSystemUtils.FileDelete(writeFile.FileName);
            var setting = UnitTestHelper.ReaderGetAllFormats();

            UnitTestInitializeCsv.MimicSQLReader.AddSetting(setting);
            writeFile.SqlStatement = setting.ID;
            writeFile.FileFormat.FieldDelimiter = "|";
            writeFile.ColumnCollection.AddIfNew(
                new Column("DateTime", new ValueFormatMutable()
            {
                DataType = DataType.DateTime, DateFormat = "yyyyMMdd"
            })
            {
                TimePartFormat = @"hh:mm",
                TimePart       = "Time",
                TimeZonePart   = "TZ"
            });
            var writer = new CsvFileWriter(writeFile, pd);

            var res = await writer.WriteAsync(writeFile.SqlStatement, 360, null, pd.CancellationToken);

            Assert.IsTrue(FileSystemUtils.FileExists(writeFile.FileName));
            Assert.AreEqual(1065, res, "Records");
        }
Ejemplo n.º 3
0
        public async Task WriteGZipAsync()
        {
            var pd = new MockProcessDisplay();

            var writeFile = (CsvFile)m_WriteFile.Clone();

            writeFile.FileName = UnitTestInitializeCsv.GetTestPath("BasicCSVOut.txt.gz");
            FileSystemUtils.FileDelete(writeFile.FileName);
            writeFile.FileFormat.FieldDelimiter = "|";

            var writer = new CsvFileWriter(writeFile, pd);

            var res = await writer.WriteAsync(m_WriteFile.SqlStatement, 360, null, pd.CancellationToken);

            Assert.IsTrue(FileSystemUtils.FileExists(writeFile.FileName));
            Assert.AreEqual(7, res);
        }
Ejemplo n.º 4
0
        public void ProcessDisplay()
        {
            var             writer = new CsvFileWriter(m_WriteFile, CancellationToken.None);
            IProcessDisplay prc    = new MockProcessDisplay
            {
                Maximum = 100
            };

            writer.ProcessDisplay = prc;
            int num = 0;

            prc.Progress += delegate(object sender, ProgressEventArgs e)
            {
                num = e.Value;
            };
            writer.HandleProgress("hello", 56);
            Assert.AreEqual(56, num);
        }
Ejemplo n.º 5
0
        public void Write()
        {
            var pd = new MockProcessDisplay();

            var writeFile = new CsvFile
            {
                ID       = "Write",
                FileName = Path.Combine(m_ApplicationDirectory, "BasicCSVOut.txt")
            };

            FileSystemUtils.FileDelete(writeFile.FileName);

            writeFile.SqlStatement = "Read";
            writeFile.FileFormat.FieldDelimiter = "|";

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

            Assert.IsTrue(string.IsNullOrEmpty(writer.ErrorMessage));
            writer.Progress += pd.SetProcess;
            var res = writer.Write();

            Assert.IsTrue(FileSystemUtils.FileExists(writeFile.FileName));
            Assert.AreEqual(7, res);
        }