Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.junit.jupiter.api.BeforeEach;
- import org.junit.jupiter.api.Test;
- import WorkSchedule.WorkSchedule;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import static org.junit.jupiter.api.Assertions.assertTrue;
- public class WorkScheduleTest {
- private WorkSchedule ws;
- private int size = 10;
- @BeforeEach
- void setup(){
- ws = new WorkSchedule(this.size);
- }
- @Test
- void setRequiredNumberTest_01(){
- int paramInt1 = 1;
- int paramInt2 = 1;
- int paramInt3 = 2;
- WorkSchedule.Hour[] oldArray = new WorkSchedule.Hour[this.size];
- for (int i = 0; i<this.size; i++){
- oldArray[i] = ws.readSchedule(i);
- }
- ws.setRequiredNumber(paramInt1, paramInt2, paramInt3);
- ws.addWorkingPeriod("Francisco",paramInt2,paramInt3);
- ws.addWorkingPeriod("Diogo",paramInt2,paramInt3);
- ws.addWorkingPeriod("Ana",paramInt2,paramInt3);
- this.setRequiredNumberTest(paramInt1, paramInt2, paramInt3);
- boolean match = true;
- for (int i = 0; i<this.size; i++){
- if (i >= paramInt2 && i <=paramInt3){
- continue;
- }
- if (!oldArray[i].equals(ws.readSchedule(i))){
- match = false;
- break;
- }
- }
- assertTrue(match, "The schedule has changed when it shouldn't");
- }
- void setRequiredNumberTest (int paramInt1, int paramInt2, int paramInt3){
- for (int i = paramInt2; i<=paramInt3; i++){
- WorkSchedule.Hour h = ws.readSchedule(i);
- String[] empregados = ws.workingEmployees(1, 2);
- for (String s : empregados){
- System.out.println(s);
- }
- int numEmployees = ws.workingEmployees(paramInt2,paramInt3).length;
- assertEquals(paramInt1, numEmployees, paramInt1 + "devia ser " + paramInt2);
- }
- }
- }
Add Comment
Please, Sign In to add comment