import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class CardLockTest {

	@Test
	@DisplayName("Tests conditions for locking the card door")
	void test() {
		CardLock lock = new CardLock();
		System.out.println();
 
		SmartCard cardA = new SmartCard("Anna Undergrad");
		SmartCard cardB = new SmartCard("Dr. Bob Lecturer");
		cardB.setStaff(true);
 
		assertTrue(cardA.getOwner().equals("Anna Undergrad"));
		lock.swipeCard(cardA);
		assertEquals(lock.getLastCardSeen(), cardA, "Tests that the cardlast is seen is correct");
				
		assertTrue(cardB.getOwner().equals("Dr. Bob Lecturer"));
		lock.swipeCard(cardB);
		assertEquals(lock.getLastCardSeen(), cardB, "Tests that the cardlast is seen is correct");
 		
		lock.swipeCard(cardA);
		assertFalse(lock.isUnlocked(), "Tests that the is locked");
		lock.swipeCard(cardB);
		assertTrue(lock.isUnlocked(), "Tests that the is unlocked");

		lock.toggleStudentAccess();
		lock.swipeCard(cardA);
		assertTrue(lock.isUnlocked(), "Tests that the is unlocked");
		
		lock.swipeCard(cardB);
		assertTrue(lock.isUnlocked(), "Tests that the is unlocked");
 
		lock.toggleStudentAccess();
		lock.swipeCard(cardA);
		assertFalse(lock.isUnlocked(), "Tests that the is locked");
		
		lock.swipeCard(cardB);
		assertTrue(lock.isUnlocked(), "Tests that the is unlocked");
 
	}

}
