예제 #1
0
        public void ReadDrawTest()
        {
            string file           = Resources.CFile;
            var    personLookup   = new CFile.PersonLookup((key, name, nationalityCode) => PersonLookup(key, name, nationalityCode));
            var    competitorList = new PersonCompetitorList();

            using (var reader = new StringReader(file))
                competitorList.Competitors = new List <CompetitorBase>(CFile.ReadPersonCompetitors(reader, personLookup));

            IList <Race> draw;

            using (var reader = new StringReader(file))
                draw = CFile.ReadDraw(reader, competitorList.Competitors).ToList();

            Assert.AreEqual(21, draw.Count);
            Assert.IsTrue(draw.Select(r => r.Heat).Distinct().SequenceEqual(Enumerable.Range(1, 11)));
            Assert.IsTrue(draw.All(r => r.Competitor != null));
            Assert.AreEqual(0, draw[9].Lane);
            Assert.AreEqual(1, draw[10].Color);
        }
예제 #2
0
        public void ReadPersonCompetitorsTest()
        {
            string file           = Resources.CFile;
            int    personsCreated = 0;
            var    personLookup   = new CFile.PersonLookup((key, name, nationalityCode) => PersonLookup(key, name, nationalityCode, p => { personsCreated++; }));

            IList <PersonCompetitor> competitors;

            using (var reader = new StringReader(file))
                competitors = CFile.ReadPersonCompetitors(reader, personLookup, "NED").ToList();

            Assert.AreEqual(21, competitors.Count);
            Assert.AreEqual(Persons["HV42013"], competitors[3].Person);
            Assert.AreEqual(20, personsCreated);
            Assert.IsTrue(competitors.All(c => c.NationalityCode == "NED"));
            Assert.AreEqual(21, competitors[0].StartNumber);
            Assert.AreEqual("Annouk", competitors[0].Name.FirstName);
            Assert.AreEqual("vd", competitors[0].Name.SurnamePrefix);
            Assert.AreEqual("Weijden", competitors[0].Name.Surname);
            Assert.AreEqual("Wüst", competitors[17].Name.Surname);
        }