public async Task AdvancedParserTest()
        {

            //"Don't blink," said the Doctor    the Doctor 
            //"" double quotes                  Random Text
            //"" "" two sets of double quotes   More Random Text

            // Setup
            string expectedQuote1 = "\"Don't blink,\" said the Doctor";
            string expectedQuote2 = "\"\" double quotes";
            string expectedQuote3 = "\"\" \"\" two sets of double quotes";

            string expectedAuthor1 = "the Doctor";
            string expectedAuthor2 = "Random Text";
            string expectedAuthor3 = "More Random Text";


            // Test
            CsvParser csvParser = new CsvParser();
            csvParser.RawText = this._complexCsvFragment;
            var results = await csvParser.Parse() as List<Dictionary<string, string>>;

            // Assert
            Assert.IsTrue(results.Count == 3);
            Assert.AreEqual(expectedQuote1, results[0]["Quote"]);


        }
예제 #2
0
        public async Task CSVParsingRecordCountTest()
        {
            // Setup
            var expectedRecordCount = this._testCSVFragment.Split('\n').Length - 1;

            // Test
            CsvParser csvParser = new CsvParser();
            csvParser.RawText = this._testCSVFragment;
            var results = await csvParser.Parse() as List<Dictionary<string,string>>;

            // Assert
            Assert.AreEqual(expectedRecordCount, results.Count);

        }
예제 #3
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            HttpClient client = new HttpClient();
            string earthQuakeData = await client.GetStringAsync("https://data.consumerfinance.gov/api/views/s6ew-h6mp/rows.csv?accessType=DOWNLOAD");

            CsvParser csvParser = new CsvParser();
            csvParser.RawText = earthQuakeData;

            var results = await csvParser.Parse();

            ConvertDictionaryToViewModel(results);

            this.lbxEarthquake.ItemsSource = this._earthQuakeDataList;

        }
예제 #4
0
        public async Task CSVParsingCommaTest()
        {
            // Setup
            var expectedRecord7Title = "ZoomData Makes Everyone a Data Scientist, 5 DCTech Startups to Watch, and NAB Partners with 1776";
            var expectedRecord9Title = "Pope Francis Comes to Town, Papal Surge Pricing, and Startup Weekend DC";

            // Test
            CsvParser csvParser = new CsvParser();
            csvParser.RawText = this._testCSVFragment;
            var results = await csvParser.Parse() as List<Dictionary<string, string>>;

            var actualRecord7Title = results[7]["Title"];
            var actualRecord9Title = results[9]["Title"];

            // Assert
            Assert.AreEqual(expectedRecord7Title, actualRecord7Title);
            Assert.AreEqual(expectedRecord9Title, actualRecord9Title);

        }
예제 #5
0
        private async void DownloadAndParseData()
        {
            CsvParser csvParser = new CsvParser();
            var rawText = await DownloadCsvData();
            csvParser.RawText = rawText;

            this.Data = await csvParser.Parse() as IEnumerable<Dictionary<string, string>>;

            BuildPivotContent();


        }