Ejemplo n.º 1
0
        public void WriteAllAsync_DataTransformerIsNull_ThrowsException()
        {
            ThrowsAsync <DataTransformerIsNullException>(async() =>
            {
                var headers = new[] { "Header#1", "Header#2", "Header#3" };

                var data = new[]
                {
                    new [] { "1", "2", "3" },
                    new [] { "4", "5", "6" }
                };

                using (var dialect = new Dialect
                {
                    DoubleQuote = true,
                    Delimiter = ';',
                    Quote = '"',
                    Escape = '\\',
                    SkipInitialSpace = true,
                    LineTerminator = "\n\r",
                    Quoting = QuoteStyle.QuoteNone,
                    Strict = true,
                    HasHeader = false
                })
                {
                    using (var adapter = new CSVAdapter(dialect, new StringWriter(), headers))
                    {
                        await adapter.WriteAllAsync(data, null);
                    }
                }
            });
        }
Ejemplo n.º 2
0
        public void WriteAllAsync_NotEqualCellCountInRows_ThrowsException()
        {
            ThrowsAsync <NotEqualCellCountInRowsException>(async() =>
            {
                var headers = new[] { "Header#1", "Header#2", "Header#3" };

                var data = new[]
                {
                    new [] { "1", "2", "3" },
                    new [] { "4", "5" }
                };

                var transformer = new NullTransformerForAdapterTesting(headers, data);

                using (var dialect = new Dialect
                {
                    DoubleQuote = true,
                    Delimiter = ';',
                    Quote = '"',
                    Escape = '\\',
                    SkipInitialSpace = true,
                    LineTerminator = "\n\r",
                    Quoting = QuoteStyle.QuoteNone,
                    Strict = true,
                    HasHeader = false
                })
                {
                    using (var adapter = new CSVAdapter(dialect, new StringWriter(), null))
                    {
                        await adapter.WriteAllAsync(data, transformer);
                    }
                }
            });
        }
Ejemplo n.º 3
0
        public async Task WriteAllAsync_WithHeader_WroteRecords()
        {
            var headers = new[] { "Header#1", "Header#2", "Header#3" };

            var data = new[]
            {
                new [] { "1", "2", "3" },
                new [] { "4", "5", "6" }
            };

            var transformer = new NullTransformerForAdapterTesting(headers, data);

            using (var dialect = new Dialect
            {
                DoubleQuote = true,
                Delimiter = ';',
                Quote = '"',
                Escape = '\\',
                SkipInitialSpace = true,
                LineTerminator = "\n\r",
                Quoting = QuoteStyle.QuoteNone,
                Strict = true,
                HasHeader = true
            })
            {
                using (var adapter = new CSVAdapter(dialect, new StringWriter(), headers))
                {
                    await adapter.WriteAllAsync(data, transformer);
                }
            }
        }