Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package diadia2;
- import static org.junit.Assert.*;
- import ambiente.Stanza;
- import attrezzi.Attrezzo;
- import org.junit.Before;
- import org.junit.Test;
- public class StanzaTest {
- Stanza atrio;
- Stanza aulaN;
- Stanza aulaN10;
- Stanza laboratorio;
- Stanza biblioteca;
- Attrezzo martello;
- @Before
- public void setUp() throws Exception {
- this.atrio = new Stanza("Atrio");
- this.aulaN = new Stanza("Aula N");
- this.aulaN10 = new Stanza("Aula N10");
- this.laboratorio = new Stanza("Laboratorio Campus");
- this.biblioteca = new Stanza("Biblioteca");
- atrio.impostaStanzaAdiacente("nord", biblioteca);
- atrio.impostaStanzaAdiacente("est", aulaN10);
- atrio.impostaStanzaAdiacente("sud", aulaN);
- atrio.impostaStanzaAdiacente("ovest", laboratorio);
- martello = new Attrezzo("martello", 3);
- atrio.addAttrezzo(martello);
- }
- @Test
- public void testGetStanzaAdiacenteVuota() {
- assertNull(this.laboratorio.getStanzaAdiacente("ovest"));
- }
- @Test
- public void testGetStanzaAdiacenteNotNull() {
- assertEquals(this.aulaN, this.atrio.getStanzaAdiacente("est"));
- }
- @Test
- public void testGetStanzaAdiacenteStringaVuota() {
- assertNull(this.atrio.getStanzaAdiacente(""));
- }
- @Test
- public void testGetStanzaAdiacenteNull() {
- assertNull(this.atrio.getStanzaAdiacente(null));
- }
- @Test
- public void testAddAttrezzoStanzaPiena() {
- this.atrio.addAttrezzo(new Attrezzo("Pentola", 1));
- this.atrio.addAttrezzo(new Attrezzo("Bicchiere", 1));
- this.atrio.addAttrezzo(new Attrezzo("Bottiglia", 1));
- this.atrio.addAttrezzo(new Attrezzo("Cuscino", 1));
- this.atrio.addAttrezzo(new Attrezzo("Profumo", 1));
- this.atrio.addAttrezzo( new Attrezzo("Coltello", 1));
- this.atrio.addAttrezzo(new Attrezzo("Pupazzo", 1));
- this.atrio.addAttrezzo(new Attrezzo("Cappello", 1));
- this.atrio.addAttrezzo(new Attrezzo("Sveglia", 1));
- assertFalse(this.atrio.addAttrezzo(new Attrezzo ("Specchio", 1)));
- }
- @Test
- public void testAddAttrezzoNotNull() {
- assertTrue(this.atrio.addAttrezzo(new Attrezzo("Sveglia", 1)));
- }
- @Test
- public void testAddAttrezzoNull() {
- assertFalse(this.atrio.addAttrezzo(null));
- }
- @Test
- public void testHasAttrezzoNonTrovato() {
- assertFalse(this.atrio.hasAttrezzo("Lavatrice"));
- }
- @Test
- public void testHasAttrezzoTrovato() {
- assertTrue(this.atrio.hasAttrezzo("Specchio"));
- }
- @Test
- public void testHasAttrezzoNull() {
- assertFalse(this.atrio.hasAttrezzo(null));
- }
- @Test
- public void testHasAttrezzoStringaVuota() {
- assertFalse(this.atrio.hasAttrezzo(""));
- }
- @Test
- public void testGetAttrezzoStringaVuota() {
- assertNull(this.atrio.getAttrezzo(""));
- }
- @Test
- public void testGetAttrezzoTrovato() {
- assertEquals(martello, this.atrio.getAttrezzo("martello"));
- }
- @Test
- public void testGetAttrezzoNonTrovato() {
- assertNull(this.atrio.getAttrezzo("cacciavite"));
- }
- @Test
- public void testGetAttrezzoNull() {
- assertNull(this.atrio.getAttrezzo(null));
- }
- @Test
- public void testRemoveAttrezzoTrovato() {
- assertTrue(this.atrio.removeAttrezzo(martello));
- }
- @Test
- public void testRemoveAttrezzoNonTrovato() {
- Attrezzo martello = new Attrezzo ("cacciavite", 5);
- assertFalse(this.atrio.removeAttrezzo(martello));
- }
- @Test
- public void testRemoveAttrezzoNull() {
- assertFalse(this.atrio.removeAttrezzo(null));
- }
- @Test
- public void testRemoveAttrezzoAppenaAggiunto() {
- Attrezzo cacciavite = new Attrezzo ("Cacciavite", 2);
- this.atrio.addAttrezzo(cacciavite);
- assertTrue(this.atrio.removeAttrezzo(cacciavite));
- }
- @Test
- public void testGetDirezioniNessunaDirezione() {
- assertArrayEquals(new String[] {}, this.aulaN10.getDirezioni());
- }
- @Test
- public void testGetDirezioniNotNull() {
- assertArrayEquals(new String[] {"nord", "est", "sud", "ovest"}, this.atrio.getDirezioni());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment