コード例 #1
0
        public void TestVoterID()
        {
            int id1 = VoterIdGenerator.CreateVoterId();
            int id2 = VoterIdGenerator.CreateVoterId();

            Assert.Greater(id2, id1);
        }
コード例 #2
0
        /// <summary>
        /// Parses the xml file into a list of persons objects
        /// </summary>
        /// <param name="xelement">the xml file</param>
        /// <returns>List of persons</returns>
        private List <Person> LoadPersons(XElement xelement)
        {
            List <Person> persons        = new List <Person>();
            var           personElements = from n in xelement.Descendants("Voter") select n;

            foreach (var element in personElements)
            {
                Person person = new Person {
                    FirstName    = element.Element("FirstName").Value,
                    LastName     = element.Element("LastName").Value,
                    Street       = element.Element("Street").Value,
                    City         = element.Element("City").Value,
                    Cpr          = element.Element("CprNo").Value,
                    PollingTable = element.Element("PollingTable").Value,
                    VoterId      = VoterIdGenerator.CreateVoterId()                //Generates a unique voter id
                };

                persons.Add(person);
            }
            return(persons);
        }