Exemplo n.º 1
0
        public void TryDataRowWriter08()
        {
            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 0, StartRow = 1, Quotation = CsvQuotation.ForceText
                }, col))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { "value1", 1 }, col),
                        new SimpleDataRow(new object[] { "value2", 2 }, col),
                        new SimpleDataRow(new object[] { "value3", 3 }, col)
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("String;Int\r\n" +
                                    "\"value1\";1\r\n" +
                                    "\"value2\";2\r\n" +
                                    "\"value3\";3\r\n", text);
                }
            }
        }
Exemplo n.º 2
0
        public void TryDataRowWriter12()
        {
            // HeaderRow > StartRow
            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 2, StartRow = 0
                }, col))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { "value1", 1 }, col),
                        new SimpleDataRow(new object[] { "value2", 2 }, col),
                        new SimpleDataRow(new object[] { "value3", 3 }, col)
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("String;Int\r\n" +
                                    "value1;1\r\n" +
                                    "value2;2\r\n" +
                                    "value3;3\r\n", text);
                }
            }
        }
Exemplo n.º 3
0
        public void TryDataRowWriter06()
        {
            //mit TextFixedSettings
            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextFixedSettings()
                {
                    Padding = ' ', Lengths = new int[] { 10, 3 }, HeaderRow = 1
                }, col))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { "value1", 123 }, col),
                        new SimpleDataRow(new object[] { "value2", 234 }, col),
                        new SimpleDataRow(new object[] { "value3", 345 }, col)
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("String    Int\r\n" +
                                    "value1  123\r\n" +
                                    "value2  234\r\n" +
                                    "\"value3\"  345\r\n", text);
                }
            }
        }
Exemplo n.º 4
0
        public void TryDataRowWriter05()
        {
            //Sonderzeichen
            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 0, StartRow = 1
                }, col2))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { "äüö", -1 }, col2),
                        new SimpleDataRow(new object[] { "@><", 2 }, col2),
                        new SimpleDataRow(new object[] { "*'#", 3 }, col2),
                        new SimpleDataRow(new object[] { "!§$%&()=?²", 42 }, col2)
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("String;!§$%&/()=*+'#><|\r\n" +
                                    "äüö;-1\r\n" +
                                    "@><;2\r\n" +
                                    "*'#;3\r\n" +
                                    "!§$%&()=?²;42\r\n", text);
                }
            }
        }
Exemplo n.º 5
0
        public void TryDataRowWriter04()
        {
            //wrong Datatype

            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 0, StartRow = 1, Quotation = CsvQuotation.None
                }, col))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { 1, 1 }, col),
                        new SimpleDataRow(new object[] { "value2", "intvalue" }, col),
                        new SimpleDataRow(new object[] { "value3", "3" }, col)
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("\"String\";Int\r\n" +
                                    "1;1\r\n" +
                                    "value2;intvalue\r\n" +
                                    "value3;3\r\n", text);
                }
            }
        }
Exemplo n.º 6
0
        public void TryDataRowWriter03()
        {
            //null-values

            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 0, StartRow = 1
                }, col))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { null, 1 }, col),
                        new SimpleDataRow(new object[] { "value2", null }, col),
                        new SimpleDataRow(new object[] { null, null }, col),
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("String;Int\r\n" +
                                    ";1\r\n" +
                                    "value2;\r\n" +
                                    ";\r\n", text);
                }
            }
        }
Exemplo n.º 7
0
        public void TryDataRowWriter02()
        {
            // mehr Felder als Columns
            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 0, StartRow = 1, Quotation = CsvQuotation.Normal
                }, col))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { "value1", 1, "extraValue" }, col),
                        new SimpleDataRow(new object[] { "value2", 2, "extraValue" }, col),
                        new SimpleDataRow(new object[] { "value3", 3, "extraValue" }, col)
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("String;Int\r\n" +
                                    "value1;1\r\n" +
                                    "value2;2\r\n" +
                                    "value3;3\r\n", text);
                }
            }
        }
Exemplo n.º 8
0
        public void TryDataRowWriter10()
        {
            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 0, StartRow = 1
                }, col))
                {
                    w.Write(
                        new IDataRow[]
                    {
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("String;Int\r\n", text);
                }
            }
        }
Exemplo n.º 9
0
        public void TryDataRowWriter11()
        {
            using (var sw = new StringWriter())
            {
                using (var w = new TextDataRowWriter(sw, new TextCsvSettings()
                {
                    HeaderRow = 0, StartRow = 1
                }, col3))
                {
                    w.Write(
                        new IDataRow[]
                    {
                        new SimpleDataRow(new object[] { "value1", 1 }, col3),
                        new SimpleDataRow(new object[] { "value2", 2 }, col3),
                    }
                        );

                    var text = sw.ToString();
                    Assert.AreEqual("\r\n\r\n\r\n", text);
                }
            }
        }