package junit;

import combo.CombinationLock;
import junit.framework.TestCase;

public class CombinationLockTest extends TestCase {
	private CombinationLock lock;
	
	/**
     * Sets up the test fixture. 
     * (Called before every test case method.) 
     */ 
    protected void setUp() { 
    	lock = new CombinationLock(01);
    } 
    
    /**
     * Tears down the test fixture. 
     * (Called after every test case method.) 
     */ 
    protected void tearDown() { 
         
    } 
    
    public void testIsOpen() {
    	assertEquals("Lock should be closed to start", lock.isOpen(), false);
    }
    
    public void testClose() {
    	lock.enter(0);
    	lock.enter(1);
    	lock.close();
    	assertEquals("Lock should be closed after call", lock.isOpen(), false);
    }
    
    public void testEnter() {
    	lock.enter(0);
    	lock.enter(5);
    	lock.enter(1);
    	lock.enter(0);
    	assertEquals("Lock should still be closed", lock.isOpen(), true);
    	lock.enter(1);
    	assertEquals("Lock should now be open", lock.isOpen(), true);
    	lock.enter(8);
    	assertEquals("Lock should still be open", lock.isOpen(), true);
    }
}
