Exemplo n.º 1
0
 public void validateFormatTest()
 {
     try
     {
         CandidateFormatValidator.validateFormat("a", "sds", "0732232232", "asdsa");
         Assert.IsFalse(false);
     } catch (ValidatorException)
     {
         Assert.IsTrue(true);
     }
 }
        /*
         * Reads from file
         */
        public override void readFromFile()
        {
            StreamReader reader = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                String   line   = reader.ReadLine();
                String[] tokens = line.Split('#');
                if (tokens.Length == 4)
                {
                    CandidateFormatValidator.validateFormat(tokens[0], tokens[1], tokens[2], tokens[3]);
                    Candidate candidate = new Candidate(int.Parse(tokens[0]), tokens[1], tokens[2], tokens[3]);
                    base.saveInMemory(candidate);
                }
            }
            reader.Close();
        }
Exemplo n.º 3
0
 /*
  * Formats the id
  * Throws ValidatorException if id is not integer
  */
 public override int formatId(string id)
 {
     CandidateFormatValidator.validateId(id);
     return(int.Parse(id));
 }
Exemplo n.º 4
0
 /*
  * Formats an element
  * Throws ValidatorException if format is invalid
  */
 public override Candidate formatElement(params string[] fields)
 {
     CandidateFormatValidator.validateFormat(fields[0], fields[1], fields[2], fields[3]);
     return(new Candidate(int.Parse(fields[0]), fields[1], fields[2], fields[3]));
 }