CS-PROJECTS / towerofhanoi / TowerTest.java
TowerTest.java
Raw
package towerofhanoi;

//Virginia Tech Honor Code Pledge:
//
//As a Hokie, I will conduct myself with honor and integrity at all times.
//I will not lie, cheat, or steal, nor will I accept the actions of those who
//do.
//-- Jordan Harrington (jordanha23)

/**
* @author Jordan Harrington
* @version <3/25/2020>
*/

public class TowerTest extends student.TestCase {

    private Tower test;
    private Disk disk1;
    private Disk disk2;
    private Disk disk3;

    /**
     * setUp method
     */
    public void setUp() {
        test = new Tower(Position.RIGHT);
        disk1 = new Disk(2);
        disk2 = new Disk(3);
        disk3 = new Disk(1);
    }


    /**
     * Tests position method
     */
    public void testPosition() {
        assertEquals(Position.RIGHT, test.position());
    }


    /**
     * Tests push method
     */
    public void testPush() {
        Exception thrown = null;
        try {
            test.push(null);
        }
        catch (Exception exception) {
            thrown = exception;
        }

        assertNotNull(thrown);
        assertTrue(thrown instanceof IllegalArgumentException);

        test.push(disk1);

        Exception thrown2 = null;
        try {
            test.push(disk2);
        }
        catch (Exception exception) {
            thrown2 = exception;
        }

        assertNotNull(thrown2);
        assertTrue(thrown2 instanceof IllegalStateException);

        test.push(disk3);
        assertEquals(2, test.size());

    }
}