package edu.upc.caminstech.equipstic;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
import org.springframework.util.StringUtils;

public class EdificiTests {

    private Edifici edifici;
    private Campus campus;

    @Before
    public void setUp() throws Exception {
        campus = new Campus(1, "Campus", "C");
        edifici = new Edifici(1, "EDIFICI1", "E1", "ADREÇA", "CIUTAT", "1234", campus);
    }

    @Test
    public void testEdifici() {
        assertNotNull(edifici);
    }

    @Test
    public void testGetIdEdifici() {
        assertEquals(1, edifici.getIdEdifici());
    }

    @Test
    public void testGetNom() {
        assertEquals("EDIFICI1", edifici.getNom());
    }

    @Test
    public void testGetCodi() {
        assertEquals("E1", edifici.getCodi());
    }

    @Test
    public void testGetAdreca() {
        assertEquals("ADREÇA", edifici.getAdreca());
    }

    @Test
    public void testGetCiutat() {
        assertEquals("CIUTAT", edifici.getCiutat());
    }

    @Test
    public void testGetCodiPostal() {
        assertEquals("1234", edifici.getCodiPostal());
    }

    @Test
    public void testGetCampus() {
        assertEquals(campus, edifici.getCampus());
    }

    @Test
    public void testToString() {
        assertTrue(StringUtils.substringMatch(edifici.toString(), 0, "[Edifici "));
    }

    @Test
    public void testEquals() {
        Edifici copy = new Edifici(1, "EDIFICI1", "E1", "ADREÇA", "CIUTAT", "1234", campus);
        assertEquals(copy, edifici);
    }

    @Test
    public void testNotEquals() {
        Edifici e2 = new Edifici(2, "EDIFICI2", "E2", "ADREÇA", "CIUTAT", "1234", campus);
        assertNotEquals(e2, edifici);
    }

    @Test
    public void testHashCode() {
        Edifici copy = new Edifici(1, "EDIFICI1", "E1", "ADREÇA", "CIUTAT", "1234", campus);
        assertEquals(copy.hashCode(), edifici.hashCode());
    }

}

@@ -371,75 +371,23 @@
 i = 
-new E
+e
 difici
-(1, %22EDIFICI1%22, %22E1%22, %22ADRE%C3%87A%22, %22CIUTAT%22, %221234%22, campus
+Fixture(
 );%0A 
@@ -1394,75 +1394,23 @@
 y = 
-new E
+e
 difici
-(1, %22EDIFICI1%22, %22E1%22, %22ADRE%C3%87A%22, %22CIUTAT%22, %221234%22, campus
+Fixture(
 );%0A 
@@ -1702,75 +1702,23 @@
 y = 
-new E
+e
 difici
-(1, %22EDIFICI1%22, %22E1%22, %22ADRE%C3%87A%22, %22CIUTAT%22, %221234%22, campus
+Fixture(
 );%0A 
@@ -1782,10 +1782,142 @@
 %0A    %7D%0A%0A
+    private Edifici edificiFixture() %7B%0A        return new Edifici(1, %22EDIFICI1%22, %22E1%22, %22ADRE%C3%87A%22, %22CIUTAT%22, %221234%22, campus);%0A    %7D%0A%0A%0A
 %7D%0A

extract method