public void GetDateOfBirth_WhenDateOfBirthInfoIsMissing_ShouldThrowFormatException()
        {
            Student katya = new Student
            {
                FirstName = "Katya",
                LastName = "Marincheva",
                AdditionalInfo = "From Sofia, born at"
            };

            DateTime dateOfBirth = katya.GetDateOfBirth(katya.AdditionalInfo);
        }
        public void GetDateOfBirth_WhenDateOfBirthInfoIsCorrect_ShouldPassTest()
        {
            Student katya = new Student
            {
                FirstName = "Katya",
                LastName = "Marincheva",
                AdditionalInfo = "From Sofia, born at 04.04.1963"
            };

            DateTime dateOfBirth = katya.GetDateOfBirth(katya.AdditionalInfo);
        }
Esempio n. 3
0
 /// <summary>
 ///   Check if the student is older then another student.
 /// </summary>
 /// <param name="other">The other student</param>
 /// <returns>True or false.</returns>
 public bool IsOlderThan(Student other)
 {
     try
     {
         DateTime thisStudentDateOfBirth  = this.GetDateOfBirth(this.Info);
         DateTime otherStudentDateOfBirth = other.GetDateOfBirth(other.Info);
         return(thisStudentDateOfBirth < otherStudentDateOfBirth);
     }
     catch (Exception)
     {
         throw new ArgumentException("Invalid date of birth");
     }
 }
 /// <summary>
 /// Checks if a a student is older than another one.
 /// </summary>
 /// <param name="other">
 /// The other student.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>true or false.
 /// </returns>
 /// <exception cref="ArgumentException">One or both students do not have valid date of birth information provided.
 /// </exception>
 public bool IsOlderThan(Student other)
 {
     try
     {
         DateTime thisStudentDateOfBirth  = this.GetDateOfBirth(this.AdditionalInfo);
         DateTime otherStudentDateOfBirth = other.GetDateOfBirth(other.AdditionalInfo);
         return(thisStudentDateOfBirth < otherStudentDateOfBirth);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         throw new ArgumentException("One or both students do not have valid date of birth information provided.");
     }
 }
 /// <summary>
 /// Checks if a a student is older than another one.
 /// </summary>
 /// <param name="other">
 /// The other student.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>true or false.
 /// </returns>
 /// <exception cref="ArgumentException">One or both students do not have valid date of birth information provided.
 /// </exception>
 public bool IsOlderThan(Student other)
 {
     try
     {
         DateTime thisStudentDateOfBirth = this.GetDateOfBirth(this.AdditionalInfo);
         DateTime otherStudentDateOfBirth = other.GetDateOfBirth(other.AdditionalInfo);
         return thisStudentDateOfBirth < otherStudentDateOfBirth;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         throw new ArgumentException("One or both students do not have valid date of birth information provided.");
     }
 }