Advertisement
Guest User

remove question

a guest
Nov 21st, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.50 KB | None | 0 0
  1.  /**
  2.      * ID: RMP01 - Remover uma pergunta a um teste vazio(BLB) - válido
  3.      * Input: 0
  4.      * Expected Output: false
  5.      * Output: false
  6.      * Test result: PASSED
  7.      **/
  8.     @org.junit.jupiter.api.Test
  9.     public void RemoveQuestionFromEmptyTestShouldReturnFalse() {
  10.         ITest test = new Test();
  11.  
  12.         Assertions.assertFalse(test.removeQuestion(0));
  13.  
  14.     }
  15.  
  16.  
  17.     /**
  18.      * ID: RMP03. Remover pergunta na posição -1(LB) - inválido
  19.      * Input: -1
  20.      * Expected Output: ArrayIndexOutOfBoundsException
  21.      * Output: ArrayIndexOutOfBoundsException
  22.      * Test result: PASSED
  23.      **/
  24.     @org.junit.jupiter.api.Test
  25.     public void RemoveQuestionFromNegativePositionShouldThrowAnException() {
  26.         ITest test = new Test();
  27.  
  28.         Assertions.assertThrows(ArrayIndexOutOfBoundsException.class, () -> {
  29.             test.removeQuestion(-1);
  30.         });
  31.  
  32.  
  33.     }
  34.  
  35.  
  36.     /**
  37.      * ID: RMP04. Remover pergunta na posição 0(ALB) - válido
  38.      * Input: 0
  39.      * Expected Output:true
  40.      * Output: true
  41.      * Test result: PASSED
  42.      **/
  43.     @org.junit.jupiter.api.Test
  44.     public void RemoveQuestionFromPosition0ShouldReturnTrue() {
  45.         ITest test = new Test();
  46.         Question question = new QuestionNumeric(2.0, "Questão", "Quanto é 1+1");
  47.  
  48.         try {
  49.             test.addQuestion(question);
  50.  
  51.         } catch (TestException e) {
  52.         }
  53.  
  54.         Assertions.assertTrue(test.removeQuestion(0));
  55.  
  56.     }
  57.  
  58.  
  59.     /**
  60.      * ID: RMP05. Remover pergunta na posição 1(ALB) -válido
  61.      * Input: 1
  62.      * Expected Output:true
  63.      * Output: true
  64.      * Test result: PASSED
  65.      **/
  66.     @org.junit.jupiter.api.Test
  67.     public void RemoveQuestionInPosition1ShouldReturnTrue() {
  68.         ITest test = new Test();
  69.         Question question = new QuestionNumeric(2.0, "Questão", "Quanto é 1+1");
  70.  
  71.         try {
  72.             test.addQuestion(question);
  73.             test.addQuestion(question);
  74.         } catch (TestException e) {
  75.         }
  76.  
  77.         Assertions.assertTrue(test.removeQuestion(1));
  78.  
  79.     }
  80.  
  81.  
  82.     /**
  83.      * ID: RMP06. Remover pergunta na posição 99(BUB) -válido
  84.      * Input: 99
  85.      * Expected Output:true
  86.      * Output: true
  87.      * Test result: PASSED
  88.      **/
  89.     @org.junit.jupiter.api.Test
  90.     public void RemoveQuestionFromPosition99ShouldReturnTrue() {
  91.         ITest test = new Test();
  92.         Question question = new QuestionNumeric(2.0, "Questão", "Quanto é 1+1");
  93.  
  94.         try {
  95.             for (int i = 0; i <= 99; i++) {
  96.                 test.addQuestion(question);
  97.             }
  98.         } catch (TestException e) {
  99.         }
  100.         Assertions.assertTrue(test.removeQuestion(99));
  101.     }
  102.  
  103.  
  104.     /**
  105.      * ID: RMP07. Remover pergunta na posição 100(BUB) -inválido
  106.      * Input: 100
  107.      * Expected Output:ArrayIndexOutOfBoundsException
  108.      * Output: ArrayIndexOutOfBoundsException
  109.      * Test result: PASSED
  110.      **/
  111.     @org.junit.jupiter.api.Test
  112.     public void RemoveQuestionFromPosition100ShouldThrowAnException() {
  113.         ITest test = new Test();
  114.  
  115.  
  116.         Assertions.assertThrows(ArrayIndexOutOfBoundsException.class, () -> {
  117.             test.removeQuestion(100);
  118.         });
  119.  
  120.  
  121.     }
  122.  
  123.  
  124.     /**
  125.      * ID: RMP08. Remover pergunta na posição 101(AUB) -inválido
  126.      * Input: 101
  127.      * Expected Output:ArrayIndexOutOfBoundsException
  128.      * Output: ArrayIndexOutOfBoundsException
  129.      * Test result: PASSED
  130.      **/
  131.     @org.junit.jupiter.api.Test
  132.     public void RemoveQuestionFromPosition101ShouldThrowAnException() {
  133.         ITest test = new Test();
  134.  
  135.  
  136.         Assertions.assertThrows(ArrayIndexOutOfBoundsException.class, () -> {
  137.             test.removeQuestion(101);
  138.         });
  139.  
  140.  
  141.     }
  142.  
  143.     /**
  144.      * ID: RMP09. Remover pergunta na posição 103(UB) -inválido
  145.      * Input: 103
  146.      * Expected Output:ArrayIndexOutOfBoundsException
  147.      * Output: ArrayIndexOutOfBoundsException
  148.      * Test result: PASSED
  149.      **/
  150.     @org.junit.jupiter.api.Test
  151.     public void RemoveQuestionFromPosition103ShouldThrowAnException() {
  152.         ITest test = new Test();
  153.  
  154.  
  155.         Assertions.assertThrows(ArrayIndexOutOfBoundsException.class, () -> {
  156.             test.removeQuestion(101);
  157.         });
  158.  
  159.  
  160.     }
  161.  
  162.  
  163.     /**
  164.      * ID:RMP10. Remove pergunta nula pela posição -inválido
  165.      * Input: 55
  166.      * Expected Output:false
  167.      * Output: false
  168.      * Test result: PASSED
  169.      **/
  170.     @org.junit.jupiter.api.Test
  171.     public void RemoveNullQuestionShouldReturnFalse() {
  172.         ITest test = new Test();
  173.         Question question = new QuestionNumeric(2.0, "Questão", "Quanto é 1+1");
  174.         try {
  175.             test.addQuestion(question);
  176.             test.addQuestion(question);
  177.         } catch (TestException e) {
  178.         }
  179.  
  180.         Assertions.assertFalse(test.removeQuestion(55));
  181.  
  182.     }
  183.  
  184.  
  185.     /**
  186.      * ID: RMP11. Remove pergunta que existe via referência -válido
  187.      * Input: question2
  188.      * Expected Output:true
  189.      * Output: true
  190.      * Test result: PASSED
  191.      **/
  192.     @org.junit.jupiter.api.Test
  193.     public void RemoveExistingQuestionByReferenceShouldReturnTrue() {
  194.         ITest test = new Test();
  195.         Question question1 = new QuestionNumeric(2.0, "Questão-1", "Quanto é 1+1?");
  196.         Question question2 = new QuestionNumeric(4.0, "Questão-2", "Quanto é 2+2?");
  197.         Question question3 = new QuestionNumeric(6.0, "Questão-3", "Quanto é 3+3?");
  198.  
  199.         try {
  200.  
  201.             test.addQuestion(question1);
  202.             test.addQuestion(question2);
  203.             test.addQuestion(question3);
  204.  
  205.         } catch (TestException e) {
  206.         }
  207.  
  208.         Assertions.assertTrue(test.removeQuestion(question2));
  209.  
  210.     }
  211.  
  212.  
  213.     /**
  214.      * ID: RMP12. Remove pergunta que não existe via referência. -inválido
  215.      * Input: question3
  216.      * Expected Output:false
  217.      * Output: false
  218.      * Test result: PASSED
  219.      **/
  220.     @org.junit.jupiter.api.Test
  221.     public void RemoveNonExistingQuestionByReferenceShouldReturnTrue() { // teste valido
  222.         ITest test = new Test();
  223.         Question question1 = new QuestionNumeric(2.0, "Questão-1", "Quanto é 1+1?");
  224.         Question question2 = new QuestionNumeric(4.0, "Questão-2", "Quanto é 2+2?");
  225.         Question question3 = new QuestionNumeric(6.0, "Questão-3", "Quanto é 3+3?");
  226.  
  227.         try {
  228.  
  229.             test.addQuestion(question1);
  230.             test.addQuestion(question2);
  231.  
  232.  
  233.         } catch (TestException e) {
  234.         }
  235.  
  236.         Assertions.assertFalse(test.removeQuestion(question3));
  237.  
  238.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement