예제 #1
0
 public void ValidName_ReturnsTrueForValidNames()
 {
     Assert.True(DoctorValidator.ValidName("John Smith"));
     Assert.True(DoctorValidator.ValidName("Rose Tyler"));
     Assert.True(DoctorValidator.ValidName("Christopher Eccleston"));
     Assert.False(DoctorValidator.ValidName("Doctor"));
 }
예제 #2
0
        /// <summary>
        /// Finds information about a given Doctor by actor name.
        /// </summary>
        /// <param name="name">The actor's name to look up.</param>
        /// <returns>Information about the doctor as portrayed by the given actor.</returns>
        public Doctor GetDoctorByName(string name)
        {
            // TODO: Add partial name matching.
            if (!DoctorValidator.ValidName(name))
            {
                return(null);
            }

            return(_theDoctors.Find(doc => doc.ActorName.Equals(name, StringComparison.CurrentCultureIgnoreCase)));
        }
예제 #3
0
 public void ValidName_ReturnsFalseForMoreThanTwoNames()
 {
     Assert.False(DoctorValidator.ValidName("Frank Smith Halloway"));
     Assert.False(DoctorValidator.ValidName("John Jacob Jingleheimer Smith"));
 }
예제 #4
0
 public void ValidName_ReturnsFalseForSingleNames()
 {
     Assert.False(DoctorValidator.ValidName("Frank"));
 }
예제 #5
0
 public void ValidName_ReturnsFalseFromInvalidCharacters()
 {
     Assert.False(DoctorValidator.ValidName("Doc.tor W&*ho"));
 }
예제 #6
0
 public void ValidName_ReturnsFalseFromEmptyString()
 {
     Assert.False(DoctorValidator.ValidName(string.Empty));
 }
예제 #7
0
 public void ValidName_ReturnsFalseFromNullInput()
 {
     Assert.False(DoctorValidator.ValidName(null));
 }