Пример #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
 public void ValidYear_ReturnsTrueForValidYears()
 {
     Assert.True(DoctorValidator.ValidYear(1963));
     Assert.True(DoctorValidator.ValidYear(1970));
     Assert.True(DoctorValidator.ValidYear(1995));
     Assert.True(DoctorValidator.ValidYear(2003));
     Assert.True(DoctorValidator.ValidYear(2011));
     Assert.True(DoctorValidator.ValidYear(2049));
 }
Пример #3
0
        /// <summary>
        /// Gets the doctors who portrayed the doctor in a given year.
        /// </summary>
        /// <param name="year">The year to lookup doctors by.</param>
        /// <returns>The doctors who portrayed the doctor in a given year.</returns>
        public IEnumerable <Doctor> GetDoctorsForYear(int year)
        {
            if (!DoctorValidator.ValidYear(year))
            {
                return(new List <Doctor>());
            }

            return(_theDoctors.Where(doc => doc.Years.Contains(year)));
        }
Пример #4
0
        public EditDoctorViewModel(DoctorModel doctor)
        {
            // Property
            Doctor          = doctor;
            ValidationRules = new DoctorValidator();

            // Command
            PutCommand = new Command(Put);
        }
        // ctor
        public AddDoctorViewModel()
        {
            // Property
            Doctor          = new DoctorModel();
            ValidationRules = new DoctorValidator();

            // Command
            PostCommand = new Command(Post);
        }
Пример #6
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)));
        }
Пример #7
0
        public JsonResult Delete(int id)
        {
            var request = new DoctorRequest
            {
                Data = new DoctorModel {
                    Id = id, Account = Account
                },
                Action = ClinicEnums.Action.DELETE.ToString()
            };

            DoctorResponse _response = new DoctorValidator(_unitOfWork).Validate(request);

            return(Json(new { Status = _response.Status, Message = _response.Message }, JsonRequestBehavior.AllowGet));
        }
Пример #8
0
        public ActionResult Edit(DoctorModel model)
        {
            model.Account = Account;

            var request = new DoctorRequest
            {
                Data = model
            };

            DoctorResponse _response = new DoctorValidator(_unitOfWork).Validate(request);

            ViewBag.Response    = $"{_response.Status};{_response.Message}";
            ViewBag.DoctorTypes = BindDropDownDoctorType();

            return(View());
        }
Пример #9
0
        public ActionResult Create(DoctorModel model)
        {
            model.Account = Account;

            // set as paramedic
            model.TypeID = 1;

            var request = new DoctorRequest {
                Data = model
            };

            DoctorResponse _response = new DoctorValidator(_unitOfWork, _context).Validate(request);

            ViewBag.Response         = $"{_response.Status};{_response.Message}";
            ViewBag.DoctorTypes      = BindDropDownDoctorType();
            ViewBag.OrganizationList = BindDropDownOrganization();

            return(View());
        }
Пример #10
0
 public void ValidYear_ReturnsFalseForYearsSignificantlyAfterCurrentYear()
 {
     Assert.False(DoctorValidator.ValidYear(2050));
 }
Пример #11
0
 public void ValidYear_ReturnsFalseForYearsBeforeShowStart()
 {
     Assert.False(DoctorValidator.ValidYear(1962));
 }
Пример #12
0
 public void ValidName_ReturnsFalseForMoreThanTwoNames()
 {
     Assert.False(DoctorValidator.ValidName("Frank Smith Halloway"));
     Assert.False(DoctorValidator.ValidName("John Jacob Jingleheimer Smith"));
 }
Пример #13
0
 public void ValidName_ReturnsFalseForSingleNames()
 {
     Assert.False(DoctorValidator.ValidName("Frank"));
 }
Пример #14
0
 public void ValidName_ReturnsFalseFromInvalidCharacters()
 {
     Assert.False(DoctorValidator.ValidName("Doc.tor W&*ho"));
 }
Пример #15
0
 public void ValidName_ReturnsFalseFromEmptyString()
 {
     Assert.False(DoctorValidator.ValidName(string.Empty));
 }
Пример #16
0
 public void ValidName_ReturnsFalseFromNullInput()
 {
     Assert.False(DoctorValidator.ValidName(null));
 }