Example #1
0
        public void SingleBracket()
        {
            string toParse = "date={date2=\"1770.12.5\"}";
            var    data    = toParse.ToStream();

            Dater actual = new Dater();
            Dictionary <string, Action <ParadoxParser> > dictionary = new Dictionary <string, Action <ParadoxParser> >
            {
                { "date", x => x.Parse(actual) }
            };

            ParadoxParser.Parse(data, dictionary.ParserAdapter());
            Assert.Equal(new DateTime(1770, 12, 5), actual.Date);
        }
Example #2
0
        public void MultipleBracket()
        {
            var data = ("date={date2=\"1770.12.5\"}" + Environment.NewLine +
                        "date={date2=\"1666.6.6\"}").ToStream();
            List <Dater> actual = new List <Dater>();
            Dictionary <string, Action <ParadoxParser> > dictionary = new Dictionary <string, Action <ParadoxParser> >
            {
                { "date", x => {
                      Dater newDate = new Dater();
                      x.Parse(newDate);
                      actual.Add(newDate);
                  } }
            };

            ParadoxParser.Parse(data, dictionary.ParserAdapter());

            List <DateTime> expected = new List <DateTime>
            {
                new DateTime(1770, 12, 5),
                new DateTime(1666, 6, 6)
            };

            Assert.Equal(expected, actual.Select(x => x.Date));
        }