/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lpa.model;
import java.util.List;
import junit.framework.TestCase;
import lpa.model.Edge.EdgeState;
/**
*
* @author Dimitriy Leonov
*/
public class EdgeTest extends TestCase {
public EdgeTest(String testName) {
super(testName);
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
/**
* Test of nextState method, of class Edge.
*/
public void testNextState() {
System.out.println("nextState");
Edge instance = new Edge(0, 1, EdgeState.MAYBE);
instance.nextState();
assertEquals("Illegal edge state", EdgeState.YES, instance.getState());
}
/**
* Test of previousState method, of class Edge.
*/
public void testPreviousState() {
System.out.println("previousState");
Edge instance = new Edge(0, 1, EdgeState.NO);
instance.nextState();
assertEquals("Illegal edge state", EdgeState.MAYBE, instance.getState());
}
/**
* Test of setState method, of class Edge.
*/
public void testSetState() {
System.out.println("setState");
EdgeState s = EdgeState.MAYBE;
Edge instance = new Edge(0, 1, EdgeState.NO);
instance.setState(s);
assertEquals("Illegal edge state", s, instance.getState());
}
/**
* Test of getState method, of class Edge.
*/
public void testGetState() {
System.out.println("getState");
Edge instance = new Edge(0, 1, EdgeState.NO);
assertEquals("Illegal edge state", EdgeState.NO, instance.getState());
}
/**
* Test of isVertical method, of class Edge.
*/
public void testIsVertical() {
System.out.println("isVertical");
Edge instance = new Edge(0, 1, EdgeState.MAYBE);
assertEquals("Edge has incorrect orientation", false, instance.isVertical());
}
/**
* Test of isHorizontal method, of class Edge.
*/
public void testIsHorizontal() {
System.out.println("isHorizontal");
Edge instance = new Edge(0, 1, EdgeState.MAYBE);
assertEquals("Edge has incorrect orientation", true, instance.isHorizontal());
}
/**
* Test of toString method, of class Edge.
*/
public void testToString() {
System.out.println("toString");
Edge instance = new Edge(0, 1, EdgeState.MAYBE);
assertEquals("Incorrect string representation", ".", instance.toString());
instance = new Edge(0, 1, EdgeState.NO);
assertEquals("Incorrect string representation", " ", instance.toString());
instance = new Edge(0, 1, EdgeState.YES);
assertEquals("Incorrect string representation", "-", instance.toString());
}
/**
* Test of getAdjacentEdges method, of class Edge.
*/
public void testGetAdjacentEdges() {
System.out.println("getAdjacentEdges");
Grid g = new Grid(5, 5);
Edge instance = (Edge) g.getGridElements().get(1); //first edge
List result = instance.getAdjacentEdges();
assertEquals("Incorrect number of edges", result.size(), 0); //only yes-edges are counted
}
}