Exemplo n.º 1
0
        public void CSVWithHeadersMultiRowTest1()
        {
            //create the delimiter builder
            var DelimiterBuilder = new DelimiterCreator(new string[] { "column1", "column2", "column3", "column4" }, CSVDelimiter);

            //add 2 rows
            DelimiterBuilder.AddRow(new string[] { "1", "2", "3", "4" });
            DelimiterBuilder.AddRow(new string[] { string.Empty, "6", null, "8" });

            //grab the resdult
            string Result = DelimiterBuilder.WriteData();

            //split the text result into columns
            var SplitTextResult = ParseResultsLazy(Result).ToArray();

            //check the results
            Assert.Equal("column1", SplitTextResult[0].ColumnData[0]);
            Assert.Equal("column2", SplitTextResult[0].ColumnData[1]);
            Assert.Equal("column3", SplitTextResult[0].ColumnData[2]);
            Assert.Equal("column4", SplitTextResult[0].ColumnData[3]);

            Assert.Equal("1", SplitTextResult[1].ColumnData[0]);
            Assert.Equal("2", SplitTextResult[1].ColumnData[1]);
            Assert.Equal("3", SplitTextResult[1].ColumnData[2]);
            Assert.Equal("4", SplitTextResult[1].ColumnData[3]);

            Assert.Equal(string.Empty, SplitTextResult[2].ColumnData[0]);
            Assert.Equal("6", SplitTextResult[2].ColumnData[1]);
            Assert.Equal(string.Empty, SplitTextResult[2].ColumnData[2]);
            Assert.Equal("8", SplitTextResult[2].ColumnData[3]);
        }
Exemplo n.º 2
0
        public void CSVWithHeadersMultiRowBulkLoadTest1()
        {
            //create the delimiter builder
            var DelimiterBuilder = new DelimiterCreator(new string[] { "column1", "column2", "column3", "column4" }, CSVDelimiter);

            //create list of rows
            var RowsToAdd = new List<DelimiterRow>();

            //RowsToAdd 2 rows to the list
            RowsToAdd.Add(new DelimiterRow(new string[] { "1", "2", "3", "4" }));
            RowsToAdd.Add(new DelimiterRow(new string[] { string.Empty, "6", null, "8" }));

            //push those rows now
            DelimiterBuilder.AddRowRange(RowsToAdd);

            //grab the resdult
            string Result = DelimiterBuilder.WriteData();

            //split the text result into columns
            var SplitTextResult = ParseResultsLazy(Result).ToArray();

            //check the results
            Assert.Equal("column1", SplitTextResult[0].ColumnData[0]);
            Assert.Equal("column2", SplitTextResult[0].ColumnData[1]);
            Assert.Equal("column3", SplitTextResult[0].ColumnData[2]);
            Assert.Equal("column4", SplitTextResult[0].ColumnData[3]);

            Assert.Equal("1", SplitTextResult[1].ColumnData[0]);
            Assert.Equal("2", SplitTextResult[1].ColumnData[1]);
            Assert.Equal("3", SplitTextResult[1].ColumnData[2]);
            Assert.Equal("4", SplitTextResult[1].ColumnData[3]);

            Assert.Equal(string.Empty, SplitTextResult[2].ColumnData[0]);
            Assert.Equal("6", SplitTextResult[2].ColumnData[1]);
            Assert.Equal(string.Empty, SplitTextResult[2].ColumnData[2]);
            Assert.Equal("8", SplitTextResult[2].ColumnData[3]);
        }
Exemplo n.º 3
0
        public void CSVWithoutHeadersTest2()
        {
            //create the delimiter builder
            var DelimiterBuilder = new DelimiterCreator(CSVDelimiter);

            //add a row
            DelimiterBuilder.AddRow(new string[] { "1", "2", "3", "4" });

            //what is the final output of creator
            string Result = DelimiterBuilder.WriteData();

            //split the text result into columns
            var SplitTextResult = ParseResultsLazy(Result).ToArray();

            //check the results
            Assert.Equal("1", SplitTextResult[0].ColumnData[0]);
            Assert.Equal("2", SplitTextResult[0].ColumnData[1]);
            Assert.Equal("3", SplitTextResult[0].ColumnData[2]);
            Assert.Equal("4", SplitTextResult[0].ColumnData[3]);
        }
Exemplo n.º 4
0
        public void CSVWithoutHeadersBulkLoadTest1()
        {
            //create the delimiter builder
            var DelimiterBuilder = new DelimiterCreator(CSVDelimiter);

            //create list of rows
            var RowsToAdd = new List<DelimiterRow>();

            //add a row
            RowsToAdd.Add(new DelimiterRow(new string[] { "1", "2", "", null }));

            //add the list (range of rows)
            DelimiterBuilder.AddRowRange(RowsToAdd);

            //what is the final output of creator
            string Result = DelimiterBuilder.WriteData();

            //split the text result into columns
            var SplitTextResult = ParseResultsLazy(Result).ToArray();

            //check the results
            Assert.Equal("1", SplitTextResult[0].ColumnData[0]);
            Assert.Equal("2", SplitTextResult[0].ColumnData[1]);
            Assert.Equal(string.Empty, SplitTextResult[0].ColumnData[2]);
            Assert.Equal(string.Empty, SplitTextResult[0].ColumnData[3]);
        }