daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package polsl.pl;
  7.  
  8. import org.junit.After;
  9. import static org.junit.Assert.*;
  10. import org.junit.Before;
  11. import org.junit.Test;
  12.  
  13. /**
  14.  *
  15.  * @author Student
  16.  */
  17. public class StudentsModelTest {
  18.  
  19.     private StudentsModel model = new StudentsModel();
  20.    
  21.     @Before
  22.     public void setup(){
  23.         for(int i = 0; i<5; i++){
  24.             StudentsHolder.getInstance().getStudents().add(new Student("student",20+i));
  25.         }
  26.     }
  27.    
  28.     @After
  29.     public void destroy(){
  30.         StudentsHolder.getInstance().getStudents().clear();
  31.     }
  32.    
  33.     @Test
  34.     public void testCreate(){
  35.         assertEquals("Should be 5 students",5,StudentsHolder.getInstance().getStudents().size());
  36.         model.createStudent(6,"Tomasz", 30);
  37.         assertEquals("Should be 6 students",6,StudentsHolder.getInstance().getStudents().size());
  38.         assertTrue("Should be Tomasz",StudentsHolder.getInstance().getStudents().get(5).getName().equals("Tomasz"));
  39.     }
  40.    
  41.     @Test
  42.     public void TestFindAll(){
  43.         assertEquals("Should be 5 students",5,model.findAllStudents().size());
  44.     }
  45.    
  46.     @Test
  47.     public void testRemove(){
  48.         assertEquals("Should be 5 students",5,StudentsHolder.getInstance().getStudents().size());
  49.         boolean removed = model.removeStudent(0);
  50.         assertEquals("Should be 4 students",4,StudentsHolder.getInstance().getStudents().size());
  51.         removed = model.removeStudent(0);
  52.         assertEquals("Should be 4 students",4,StudentsHolder.getInstance().getStudents().size());
  53.         assertFalse("Should be true", removed);
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top