예제 #1
0
        public void Should_get_the_columns_for_each_line()
        {
            var splitter = new SeparatorTextSplitter(_stringCursor);
            StringCursor text;

            Assert.IsTrue(splitter.TryGetText(0, out text));

            var columnSplitter = new DelimiterTextSplitter(text, ',');

            var columns = columnSplitter.ToList();

            Assert.AreEqual(13, columns.Count);

            Assert.AreEqual("gameid", columns[0].String);
            Assert.AreEqual("qtr", columns[1].String);
            Assert.AreEqual("min", columns[2].String);
            Assert.AreEqual("sec", columns[3].String);
            Assert.AreEqual("off", columns[4].String);
            Assert.AreEqual("def", columns[5].String);
            Assert.AreEqual("down", columns[6].String);
            Assert.AreEqual("togo", columns[7].String);
            Assert.AreEqual("ydline", columns[8].String);
            Assert.AreEqual("description", columns[9].String);
            Assert.AreEqual("offscore", columns[10].String);
            Assert.AreEqual("defscore", columns[11].String);
            Assert.AreEqual("season", columns[12].String);
        }
예제 #2
0
        public void Should_parse_all_lines_and_columns()
        {
            var splitter = new SeparatorTextSplitter(_stringCursor);
            for (int i = 0;; i++)
            {
                StringCursor text;
                if (!splitter.TryGetText(i, out text))
                    break;

                var columnSplitter = new DelimiterTextSplitter(text, ',');

                var columns = columnSplitter.ToList();
            }

            Stopwatch timer = Stopwatch.StartNew();
            int count = 0;
            for (int loop = 0; loop < 10; loop++)
            {
                splitter = new SeparatorTextSplitter(_stringCursor);
                for (count = 0;; count++)
                {
                    StringCursor text;
                    if (!splitter.TryGetText(count, out text))
                        break;

                    var columnSplitter = new DelimiterTextSplitter(text, ',');

                    var columns = columnSplitter.ToList();
                }
            }
            timer.Stop();

            Console.WriteLine("Line Count: {0}, Time: {1}ms", count, timer.ElapsedMilliseconds / 10);

            Assert.AreEqual(44855, count);
        }