Add oving 5

This commit is contained in:
Andreas Omholt Olsen
2026-02-09 15:28:09 +01:00
parent 6193e26ba1
commit 55c36a603a
33 changed files with 1586 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
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");
}
}