public void TestDeleteEmployeeByID() { onSetUp(); // Create an employee var employeeBuilder = new EmployeeBuilder().setName(NAME); var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest(); // Add them to the database employeeController.Post(addEmployeesRequest); //Get them from the database and find their ID var databaseEmployee = employeeController.Get(NAME); var ID = databaseEmployee.Employees.Last().PersonalId; var removeEmployeeRequest = new RemoveEmployeeRequest() { PersonalID = ID }; employeeController.Delete(removeEmployeeRequest); try { employeeController.GetEmployeeByID(ID); Assert.IsTrue(false); //Means that it found the employee so fail the test } catch { Assert.IsTrue(true); } }
public void TestAddEmployees() { onSetUp(); var employeeBuilder = new EmployeeBuilder().setName(NAME); var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest(); var response = employeeController.Post(addEmployeesRequest); var databaseEmployee = employeeRepository.GetEmployeeByName(NAME); var correctDatabaseEmploye = employeeBuilder.CreateEmployee(); Assert.IsTrue(response.Success); Assert.IsTrue(EmployeesAreEqual(new Employee(databaseEmployee), correctDatabaseEmploye)); }
public void TestGetEmployeeByID() { onSetUp(); // Create an employee var employeeBuilder = new EmployeeBuilder().setName(NAME); var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest(); // Add them to the database employeeController.Post(addEmployeesRequest); //Get them from the database and find their ID var databaseEmployee = employeeController.Get(NAME); var ID = databaseEmployee.Employees.Last().PersonalId; //Find them by their PersonalID var databaseEmployeeByID = employeeController.GetEmployeeByID(ID); //Check that they are the same person Assert.AreEqual(databaseEmployee.Employees.First().PersonalId, databaseEmployeeByID.Employees.First().PersonalId); }
public void TestAddDuplicateEmployee() { OnSetUp(); var employeeBuilder = new EmployeeBuilder().SetName(Name); _employeeRepository.AddEmployees(new List <Employee> { employeeBuilder.CreateEmployee() }); var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest(); try { _employeeController.Post(addEmployeesRequest); Assert.Fail("Expected exception to be thrown."); } catch (Exception) { Assert.IsTrue(true); } }
public void TestAddDuplicateEmployee() { onSetUp(); var employeeBuilder = new EmployeeBuilder().setName(NAME); employeeRepository.AddEmployees(new List <Employee>() { employeeBuilder.CreateEmployee() }); var addEmployeesRequest = employeeBuilder.CreateAddEmployeesRequest(); try { employeeController.Post(addEmployeesRequest); } catch (Exception) { Assert.IsTrue(false); //means that we could not add a dup, so fail the test } Assert.IsTrue(true); }