Beispiel #1
0
        public void AddEmployeeToList_InvalidEmployee_EmployeeNotAddedToList()
        {
            // Instantiate an Employee object and a private object
            DateTime dateOfBirth = new DateTime(1987, 11, 29);
            Employee employee = new Employee();
            employee.SetFirstName("Janet");
            employee.SetLastName("Moore");
            employee.SetSocialInsuranceNumber(872046458);
            var privateObject = new PrivateObject(employeeRepo);

            // Execute the method that is being tested
            privateObject.Invoke("AddEmployeeToList", employee);
            // Check if the expected result and actual result are the same
            List<Employee> employeeList = (List<Employee>)privateObject.GetField("listOfEmployees");
            Assert.AreEqual(0, employeeList.Count);
        }
Beispiel #2
0
 public void SetSocialInsuranceNumberTestInvalidTooLarge()
 {
     Employee employee = new Employee();
     bool retVal = employee.SetSocialInsuranceNumber(1112345678);
     Assert.IsFalse(retVal);
     Assert.AreEqual(employee.GetSocialInsuranceNumber(), 0);
 }
Beispiel #3
0
 public void SetSocialInsuranceNumberTestValid()
 {
     Employee employee = new Employee();
     bool retVal = employee.SetSocialInsuranceNumber(123456789);
     Assert.IsTrue(retVal);
     Assert.AreEqual(employee.GetSocialInsuranceNumber(), 123456789);
 }