Files
oops/src/test/java/oving7/train/CargoCarTest.java
Andreas Omholt Olsen 1deb0cc650 Add oving 7
2026-03-06 10:59:33 +01:00

29 lines
743 B
Java

package oving7.train;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class CargoCarTest {
private CargoCar cargoCar;
@BeforeEach
public void setUp() {
cargoCar = new CargoCar(3000, 2000);
}
@Test
@DisplayName("Check total weight")
public void testWeight() {
assertEquals(5000, cargoCar.getTotalWeight(), "Test total weight after initialization");
cargoCar.setCargoWeight(4000);
assertEquals(7000, cargoCar.getTotalWeight(),
"Test total weight after changing cargo weight");
assertEquals(4000, cargoCar.getCargoWeight(),
"Test cargo weight after changing the weight");
}
}