Files
oops/src/test/java/oving5/ticket/SingleTicketTest.java
Andreas Omholt Olsen 55c36a603a Add oving 5
2026-02-09 15:28:09 +01:00

42 lines
1.3 KiB
Java

package oving5.ticket;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class SingleTicketTest {
private Ticket ticket;
@BeforeEach
public void setUp() {
ticket = new SingleTicket();
}
@Test
@DisplayName("Check that the ticket returns true when scanned for the first time")
public void testReturnsTrueWhenScanned() {
assertTrue(this.ticket.scan(),
"The ticket should return true when scanned for the first time");
}
@Test
@DisplayName("Check that the ticket returns false when scanned for the second time")
public void testReturnsFalseWhenScannedTwice() {
ticket.scan();
assertFalse(ticket.scan(),
"The ticket should return false when scanned for the second time");
}
@Test
@DisplayName("Check that the ticket returns true when scanned for the first time after reset")
public void testReturnsFalseWhenScannedTwiceAfterReset() {
ticket.scan();
ticket = new SingleTicket();
assertTrue(ticket.scan(),
"The ticket should return true when scanned for the first time after reset");
}
}