Guest User

Untitled

a guest
Mar 26th, 2015
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.84 KB | None | 0 0
  1. package diadia2;
  2. import static org.junit.Assert.*;
  3. import ambiente.Stanza;
  4. import attrezzi.Attrezzo;
  5.  
  6. import org.junit.Before;
  7. import org.junit.Test;
  8.  
  9. public class StanzaTest {
  10.     Stanza atrio;
  11.     Stanza aulaN;
  12.     Stanza aulaN10;
  13.     Stanza laboratorio;
  14.     Stanza biblioteca;
  15.     Attrezzo martello;
  16.  
  17.     @Before
  18.     public void setUp() throws Exception {
  19.  
  20.         this.atrio = new Stanza("Atrio");
  21.         this.aulaN = new Stanza("Aula N");
  22.         this.aulaN10 = new Stanza("Aula N10");
  23.         this.laboratorio = new Stanza("Laboratorio Campus");
  24.         this.biblioteca = new Stanza("Biblioteca");
  25.  
  26.         atrio.impostaStanzaAdiacente("nord", biblioteca);
  27.         atrio.impostaStanzaAdiacente("est", aulaN10);
  28.         atrio.impostaStanzaAdiacente("sud", aulaN);
  29.         atrio.impostaStanzaAdiacente("ovest", laboratorio);
  30.  
  31.         martello = new Attrezzo("martello", 3);
  32.         atrio.addAttrezzo(martello);
  33.     }
  34.  
  35.  
  36.     @Test
  37.     public void testGetStanzaAdiacenteVuota() {
  38.         assertNull(this.laboratorio.getStanzaAdiacente("ovest"));
  39.     }
  40.  
  41.     @Test
  42.     public void testGetStanzaAdiacenteNotNull() {
  43.         assertEquals(this.aulaN, this.atrio.getStanzaAdiacente("est"));
  44.     }
  45.  
  46.     @Test
  47.     public void testGetStanzaAdiacenteStringaVuota() {
  48.         assertNull(this.atrio.getStanzaAdiacente(""));
  49.     }
  50.  
  51.     @Test
  52.     public void testGetStanzaAdiacenteNull() {
  53.         assertNull(this.atrio.getStanzaAdiacente(null));
  54.     }
  55.  
  56.     @Test
  57.     public void testAddAttrezzoStanzaPiena() {
  58.        
  59.         this.atrio.addAttrezzo(new Attrezzo("Pentola", 1));
  60.         this.atrio.addAttrezzo(new Attrezzo("Bicchiere", 1));
  61.         this.atrio.addAttrezzo(new Attrezzo("Bottiglia", 1));
  62.         this.atrio.addAttrezzo(new Attrezzo("Cuscino", 1));
  63.         this.atrio.addAttrezzo(new Attrezzo("Profumo", 1));
  64.         this.atrio.addAttrezzo( new Attrezzo("Coltello", 1));
  65.         this.atrio.addAttrezzo(new Attrezzo("Pupazzo", 1));
  66.         this.atrio.addAttrezzo(new Attrezzo("Cappello", 1));
  67.         this.atrio.addAttrezzo(new Attrezzo("Sveglia", 1));
  68.         assertFalse(this.atrio.addAttrezzo(new Attrezzo ("Specchio", 1)));
  69.     }
  70.  
  71.     @Test
  72.     public void testAddAttrezzoNotNull() {
  73.         assertTrue(this.atrio.addAttrezzo(new Attrezzo("Sveglia", 1)));
  74.     }
  75.  
  76.     @Test
  77.     public void testAddAttrezzoNull() {
  78.         assertFalse(this.atrio.addAttrezzo(null));
  79.     }
  80.  
  81.     @Test
  82.     public void testHasAttrezzoNonTrovato() {
  83.         assertFalse(this.atrio.hasAttrezzo("Lavatrice"));
  84.     }
  85.  
  86.     @Test
  87.     public void testHasAttrezzoTrovato() {
  88.         assertTrue(this.atrio.hasAttrezzo("Specchio"));
  89.     }
  90.  
  91.     @Test
  92.     public void testHasAttrezzoNull() {
  93.         assertFalse(this.atrio.hasAttrezzo(null));
  94.     }
  95.  
  96.     @Test
  97.     public void testHasAttrezzoStringaVuota() {
  98.         assertFalse(this.atrio.hasAttrezzo(""));
  99.     }
  100.  
  101.     @Test
  102.     public void testGetAttrezzoStringaVuota() {
  103.         assertNull(this.atrio.getAttrezzo(""));
  104.     }
  105.  
  106.     @Test
  107.     public void testGetAttrezzoTrovato() {
  108.         assertEquals(martello, this.atrio.getAttrezzo("martello"));
  109.     }
  110.  
  111.     @Test
  112.     public void testGetAttrezzoNonTrovato() {
  113.         assertNull(this.atrio.getAttrezzo("cacciavite"));
  114.     }
  115.    
  116.     @Test
  117.     public void testGetAttrezzoNull() {
  118.         assertNull(this.atrio.getAttrezzo(null));
  119.     }
  120.  
  121.     @Test
  122.     public void testRemoveAttrezzoTrovato() {
  123.         assertTrue(this.atrio.removeAttrezzo(martello));
  124.     }
  125.  
  126.     @Test
  127.     public void testRemoveAttrezzoNonTrovato() {
  128.         Attrezzo martello = new Attrezzo ("cacciavite", 5);
  129.         assertFalse(this.atrio.removeAttrezzo(martello));
  130.     }
  131.  
  132.     @Test
  133.     public void testRemoveAttrezzoNull() {
  134.         assertFalse(this.atrio.removeAttrezzo(null));
  135.     }
  136.  
  137.     @Test
  138.     public void testRemoveAttrezzoAppenaAggiunto() {
  139.         Attrezzo cacciavite = new Attrezzo ("Cacciavite", 2);
  140.         this.atrio.addAttrezzo(cacciavite);
  141.         assertTrue(this.atrio.removeAttrezzo(cacciavite));
  142.     }
  143.  
  144.     @Test
  145.     public void testGetDirezioniNessunaDirezione() {
  146.         assertArrayEquals(new String[] {}, this.aulaN10.getDirezioni());
  147.     }
  148.  
  149.     @Test
  150.     public void testGetDirezioniNotNull() {
  151.         assertArrayEquals(new String[] {"nord", "est", "sud", "ovest"}, this.atrio.getDirezioni());
  152.     }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment