Skip to content
Snippets Groups Projects
Commit e0ccf6b2 authored by Francesco Fontana's avatar Francesco Fontana
Browse files

VERDE: testToString di TestTreno.java supera il test

parent 5cc55818
Branches feature/Model
No related tags found
No related merge requests found
......@@ -53,11 +53,7 @@ public final class Treno {
@Override
public String toString() {
return "Treno[" +
"codice=" + codice + ", " +
"destinazione=" + destinazione + ", " +
"orario=" + orario + ", " +
"ritardo=" + ritardo + ']';
return codice + " " + destinazione + " " + orario + " " + ritardo.toMinutes();
}
}
\ No newline at end of file
import it.unimi.di.sweng.esame.model.Treno;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import static org.assertj.core.api.Assertions.assertThat;
public class TestTreno {
@Test
void testToString() {
Treno t = new Treno("NTV 3312",
"ROMA",
LocalTime.parse("14:00", DateTimeFormatter.ofPattern("H:m")),
Duration.ofMinutes(15));
assertThat(t.toString()).isEqualTo("NTV 3312 ROMA 14:00 15");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment