Esempio n. 1
0
        private bool InvalidFields()
        {
            try
            {
                var empNo = int.Parse(txtEmpNo.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("You did not enter all the fields correctly!");
                return(true);
            }
            try
            {
                var age = int.Parse(nudAge.Value.ToString());

                _validator.ValidateAge(age);
            }
            catch (Exception)
            {
                MessageBox.Show("Age has to be entered as an integer between 0001 - 9999");
                return(true);
            }

            bool emptyfields = new List <string> {
                txtEmpNo.Text, txtEmpAddress.Text, cmbCity.Text, cmbState.Text
            }
            .All(text => string.IsNullOrEmpty(text));

            if (radFemale.Checked == false && radMale.Checked == false)
            {
                emptyfields = true;
            }

            return(emptyfields);
        }
Esempio n. 2
0
        public void ValidateAge_ReturnsTrueIfValidAge(int age)
        {
            bool result = _validator.ValidateAge(age);

            Assert.IsTrue(result);
        }