Пример #1
0
        private List <string> EmitDynamicToDataTableToListOfStringsVanillaTest(DataTable dataTable)
        {
            List <string> dataoutput = new List <string>();

            foreach (dynamic output in
                     TabularDataObjectFactory.EmitDynamicObjectFromDataTable(dataTable, null, null, null, null))
            {
                dataoutput.Add(String.Format("Name = '{0}', Address = '{1}', City = '{2}'",
                                             output.Name, output.Address, output.City));
            }
            return(dataoutput);
        }
Пример #2
0
        public void TestingHelper(DataTable dataTable)
        {
            // Tests the Row Index Inclusion filtering
            List <string> TestOutputForInclusionByIndex = new List <string>();

            TestLog.WriteLine("Including rows with index 2 and 3:\n");
            foreach (dynamic output in
                     TabularDataObjectFactory.EmitDynamicObjectFromDataTable(dataTable, new int[] { 2, 3 }, null, null, null))
            {
                TestOutputForInclusionByIndex.Add(output.Name);
            }
            Assert.AreElementsEqual(new[] { "John Smith", "Patricia Doe" }, TestOutputForInclusionByIndex);

            // Tests the Row Index Exclusion filtering
            List <string> TestOutputForExclusionByIndex = new List <string>();

            foreach (dynamic output in
                     TabularDataObjectFactory.EmitDynamicObjectFromDataTable(dataTable, null, new int[] { 2, 3 }, null, null))
            {
                TestOutputForExclusionByIndex.Add(output.Name);
            }
            Assert.AreElementsEqual(new[] { "Allen Watts" }, TestOutputForExclusionByIndex);

            // Tests the Inclusion By Value filtering
            List <string> TestOutputForInclusionByValue = new List <string>();

            foreach (dynamic output in
                     TabularDataObjectFactory.EmitDynamicObjectFromDataTable(
                         dataTable, null, null, new string[] { "John Smith", "Allen Watts" }, null))
            {
                TestOutputForInclusionByValue.Add(output.Name);
            }
            Assert.AreElementsEqual(new[] { "John Smith", "Patricia Doe" }, TestOutputForInclusionByIndex);

            // Tests the Exclusion By Value filtering
            List <string> TestOutputForExclusionByValue = new List <string>();

            foreach (dynamic output in
                     TabularDataObjectFactory.EmitDynamicObjectFromDataTable(
                         dataTable, null, null, null, new string[] { "John Smith", "Allen Watts" }))
            {
                TestOutputForExclusionByValue.Add(output.Name);
            }
            Assert.AreElementsEqual(new[] { "Patricia Doe" }, TestOutputForExclusionByValue);
        }
Пример #3
0
        public void LoadCsvFileWithQuotes()
        {
            DataTable dataTable = FlatFileToDataTableBuilder.BuildFromCsvFile(@"..\Framework\Data\DataObjects\TestFileWithQuotes.csv");

            List <string> dataoutput = new List <string>();

            foreach (dynamic output in
                     TabularDataObjectFactory.EmitDynamicObjectFromDataTable(dataTable, null, null, null, null))
            {
                dataoutput.Add(String.Format("UserName = '******', Column_With_Quotes_1 = '{1}'",
                                             output.UserName, output.Column_With_Quotes_1));
            }

            Assert.AreElementsEqual(new [] {
                "UserName = '******', Column_With_Quotes_1 = '\"This is some test data's stuff\"'",
                "UserName = '******', Column_With_Quotes_1 = '\"The stuff\"'",
                "UserName = '******', Column_With_Quotes_1 = 'More test data \" \" \" '  '  '  \"'"
            },
                                    dataoutput);
        }
Пример #4
0
        public void LoadCsvFileWithCommas()
        {
            DataTable dataTable = FlatFileToDataTableBuilder.BuildFromCsvFile(@"..\Framework\Data\DataObjects\TestFileWithCommas.csv");

            List <string> dataoutput = new List <string>();

            foreach (dynamic output in
                     TabularDataObjectFactory.EmitDynamicObjectFromDataTable(dataTable, null, null, null, null))
            {
                dataoutput.Add(String.Format("Plenty_of_Commas_Just_For_You = '{0}', UserName = '******'",
                                             output.Plenty_of_Commas_Just_For_You, output.UserName));
            }

            Assert.AreElementsEqual(new[] {
                "Plenty_of_Commas_Just_For_You = 'This,is,too,many,commas,man!', UserName = '******'",
                "Plenty_of_Commas_Just_For_You = 'This,is,too,many,commas,man!', UserName = '******'",
                "Plenty_of_Commas_Just_For_You = 'More commas,,,,,,,,,,,,,,,,,,,,,,,', UserName = '******'"
            },
                                    dataoutput);
        }