xickoh

ES2 ficha 03

Nov 11th, 2020 (edited)
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. import org.junit.jupiter.api.BeforeEach;
  2. import org.junit.jupiter.api.Test;
  3. import WorkSchedule.WorkSchedule;
  4.  
  5. import static org.junit.jupiter.api.Assertions.assertEquals;
  6. import static org.junit.jupiter.api.Assertions.assertTrue;
  7.  
  8. public class WorkScheduleTest {
  9. private WorkSchedule ws;
  10. private int size = 10;
  11.  
  12. @BeforeEach
  13. void setup(){
  14.     ws = new WorkSchedule(this.size);
  15. }
  16.  
  17.  
  18. @Test
  19. void setRequiredNumberTest_01(){
  20.     int paramInt1 = 1;
  21.     int paramInt2 = 1;
  22.     int paramInt3 = 2;
  23.  
  24.     WorkSchedule.Hour[] oldArray = new WorkSchedule.Hour[this.size];
  25.  
  26.     for (int i = 0; i<this.size; i++){
  27.         oldArray[i] = ws.readSchedule(i);
  28.     }
  29.  
  30.     ws.setRequiredNumber(paramInt1, paramInt2, paramInt3);
  31.  
  32.     ws.addWorkingPeriod("Francisco",paramInt2,paramInt3);
  33.     ws.addWorkingPeriod("Diogo",paramInt2,paramInt3);
  34.     ws.addWorkingPeriod("Ana",paramInt2,paramInt3);
  35.  
  36.     this.setRequiredNumberTest(paramInt1, paramInt2, paramInt3);
  37.  
  38.     boolean match = true;
  39.     for (int i = 0; i<this.size; i++){
  40.         if (i >= paramInt2 && i <=paramInt3){
  41.             continue;
  42.         }
  43.         if (!oldArray[i].equals(ws.readSchedule(i))){
  44.             match = false;
  45.             break;
  46.         }
  47.     }
  48.  
  49.     assertTrue(match, "The schedule has changed when it shouldn't");
  50. }
  51.  
  52. void setRequiredNumberTest (int paramInt1, int paramInt2, int paramInt3){
  53.  
  54.     for (int i = paramInt2; i<=paramInt3; i++){
  55.         WorkSchedule.Hour h = ws.readSchedule(i);
  56.  
  57.         String[] empregados = ws.workingEmployees(1, 2);
  58.  
  59.         for (String s : empregados){
  60.             System.out.println(s);
  61.         }
  62.  
  63.         int numEmployees = ws.workingEmployees(paramInt2,paramInt3).length;
  64.  
  65.         assertEquals(paramInt1, numEmployees, paramInt1 + "devia ser " + paramInt2);
  66.     }
  67. }
  68.  
  69. }
  70.  
Add Comment
Please, Sign In to add comment