Guest User

Untitled

a guest
May 21st, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package adventure;
  6.  
  7. import items.Hook;
  8. import items.Rock;
  9. import org.junit.After;
  10. import org.junit.AfterClass;
  11. import org.junit.Before;
  12. import org.junit.BeforeClass;
  13. import org.junit.Test;
  14. import static org.junit.Assert.*;
  15.  
  16. import textgame.Item;
  17.  
  18. /**
  19.  *
  20.  * @author anti
  21.  */
  22. public class BackpackImplTest {
  23.    
  24.     public BackpackImplTest() {
  25.     }
  26.  
  27.     @BeforeClass
  28.     public static void setUpClass() throws Exception {
  29.     }
  30.  
  31.     @AfterClass
  32.     public static void tearDownClass() throws Exception {
  33.     }
  34.    
  35.     @Before
  36.     public void setUp() {
  37.     }
  38.    
  39.     @After
  40.     public void tearDown() {
  41.     }
  42.  
  43.     /**
  44.      * Test of add method, of class BackpackImpl.
  45.      */
  46.     @Test
  47.     public void testAdd() {
  48.         System.out.println("add");
  49.         Item item = new Rock();
  50.         BackpackImpl instance = new BackpackImpl(4);
  51.         boolean expResult = true;
  52.         boolean result = instance.add(item);
  53.         assertEquals(expResult, result);
  54.        
  55.         for(int i = 0; i < instance.getCapacity(); i++)
  56.         {
  57.             result = instance.add(item);
  58.             assertEquals(expResult, result);
  59.         }        
  60.         result = instance.add(item);
  61.         expResult = false;
  62.         assertEquals(expResult, result);
  63.     }
  64.  
  65.     /**
  66.      * Test of remove method, of class BackpackImpl.
  67.      */
  68.     @Test
  69.     public void testRemove() {
  70.         System.out.println("remove");
  71.         String string = "hak";
  72.         BackpackImpl instance = new BackpackImpl(4);
  73.         Item item = new Hook();
  74.         instance.add(item);
  75.         Item result = instance.remove(string);
  76.        
  77.         assertNotNull(result);
  78.     }
  79.  
  80. }
Add Comment
Please, Sign In to add comment