You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
package hs.fulda.de.ci.exam.project;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.mockito.junit.MockitoJUnitRunner;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
@RunWith(MockitoJUnitRunner.class)
|
|
public class AirlineTest {
|
|
|
|
Airline airline = new Airline("Pegasus", "1234");
|
|
Flight flight1 = mock(Flight.class);
|
|
HashSet<Flight> flights = new HashSet<>();
|
|
|
|
@Test
|
|
void testConstructorSetsNameParameterCorrectly() {
|
|
assertThat(airline.getName())
|
|
.describedAs("name of airline")
|
|
.isEqualTo("Pegasus");
|
|
}
|
|
|
|
@Test
|
|
void testConstructorSetsCodeParameterCorrectly() {
|
|
assertThat(airline.getCode())
|
|
.describedAs("code of airline")
|
|
.isEqualTo("1234");
|
|
}
|
|
|
|
@Test
|
|
void getFlightsReturnsEmptyListOfFlights() {
|
|
assertThat(airline.getFlights())
|
|
.describedAs("flights of airline")
|
|
.isEqualTo(flights);
|
|
}
|
|
|
|
@Test
|
|
void addFlightAddsFlightToListOfFlights() {
|
|
flights.add(flight1);
|
|
|
|
airline.addFlight(flight1);
|
|
|
|
assertThat(airline.getFlights())
|
|
.describedAs("flights of airline")
|
|
.isEqualTo(flights);
|
|
}
|
|
|
|
}
|