Package lpa.command

Source Code of lpa.command.EdgeCommandTest

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lpa.command;

import junit.framework.TestCase;
import lpa.model.Edge;
import lpa.model.Edge.EdgeState;

/**
*
* @author Dimitriy Leonov
*/
public class EdgeCommandTest extends TestCase {

    public EdgeCommandTest(String testName) {
        super(testName);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Test of execute method, of class EdgeCommand.
     */
    public void testExecute() {
        System.out.println("execute");
        Edge e = new Edge(0, 0, EdgeState.MAYBE);
        EdgeCommand instance = new EdgeCommand(e, EdgeState.NO);
        try {
            instance.execute();
        } catch (IllegalStateException ex) {
            fail("Command already executed.");
        }
       
        assertEquals("Invalid edge state after command execution", e.getState(), EdgeState.NO);
    }

    /**
     * Test of undo method, of class EdgeCommand.
     */
    public void testUndo() {
        System.out.println("undo");
        Edge e = new Edge(0, 0, EdgeState.MAYBE);
        EdgeCommand instance = new EdgeCommand(e, EdgeState.NO);
        instance.execute();
        try {
            instance.undo();
        } catch (IllegalStateException ex) {
            fail("Command wasn't executed, cannot be undone.");
        }
       
        assertEquals("Invalid edge state after command execution", e.getState(), EdgeState.MAYBE);
    }
}
TOP

Related Classes of lpa.command.EdgeCommandTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.