package me.teaisaweso.shared;

import junit.framework.Assert;
import junit.framework.TestCase;

public class EdgeTest extends TestCase {

	private Vertex mV1, mV2, mV3;

	public void setUp() throws Exception {
		mV1 = new Vertex("a");
		mV2 = new Vertex("b");
		mV3 = new Vertex("c");
	}

	/**
	 * tests that a both edge has the right properties with the implicit
	 * constructor
	 */
	public void testBothEdgeImplicit() {
		Edge e1 = new Edge(mV1, mV2);
		Assert.assertEquals(true, e1.exits(mV1));
		Assert.assertEquals(true, e1.enters(mV2));
		Assert.assertEquals(true, e1.exits(mV2));
		Assert.assertEquals(true, e1.enters(mV1));
		Assert.assertEquals(false, e1.enters(mV3));
		Assert.assertEquals(false, e1.exits(mV3));
	}

	/**
	 * tests that a both edge has the right properties with an explict
	 * constructor
	 */
	public void testBothEdgeExplicit() {
		Edge e1 = new Edge(mV2, mV3, VertexDirection.both);
		Assert.assertEquals(true, e1.exits(mV2));
		Assert.assertEquals(true, e1.enters(mV3));
		Assert.assertEquals(true, e1.exits(mV3));
		Assert.assertEquals(true, e1.enters(mV2));
		Assert.assertEquals(false, e1.enters(mV1));
		Assert.assertEquals(false, e1.exits(mV1));
	}

	/**
	 * tests a from-to edge has the right properties with an explicit
	 * constructor
	 */
	public void testFromToEdgeExplicit() {
		Edge e1 = new Edge(mV2, mV1, VertexDirection.fromTo);
		Assert.assertEquals(true, e1.exits(mV2));
		Assert.assertEquals(true, e1.enters(mV1));

		Assert.assertEquals(false, e1.exits(mV1));
		Assert.assertEquals(false, e1.enters(mV2));

		Assert.assertEquals(false, e1.enters(mV3));
		Assert.assertEquals(false, e1.exits(mV3));
	}

	/**
	 * tests a to-from edge has the right properties with an explicit
	 * constructor
	 */
	public void testToFromEdgeExplicit() {
		Edge e1 = new Edge(mV2, mV1, VertexDirection.toFrom);
		Assert.assertEquals(true, e1.exits(mV1));
		Assert.assertEquals(true, e1.enters(mV2));

		Assert.assertEquals(false, e1.exits(mV2));
		Assert.assertEquals(false, e1.enters(mV1));

		Assert.assertEquals(false, e1.enters(mV3));
		Assert.assertEquals(false, e1.exits(mV3));
	}

}

@@ -2111,11 +2111,1265 @@
 3));%0A%09%7D%0A
+%09%0A%09/**%0A%09 * tests that from vertex works%0A%09 */%0A%09public void testGetFromVertex() %7B%0A%09%09Edge e1 = new Edge(mV1, mV2);%0A%09%09Assert.assertEquals(mV1, e1.getFromVertex());%0A%09%09e1 = new Edge(mV2, mV1);%0A%09%09Assert.assertEquals(mV2, e1.getFromVertex());%0A%09%09e1 = new Edge(mV3, mV3);%0A%09%09Assert.assertEquals(mV3, e1.getFromVertex());%0A%09%7D%0A%09%0A%09/**%0A%09 * tests that to vertex works%0A%09 */%0A%09public void testGetToVertex() %7B%0A%09%09Edge e1 = new Edge(mV1, mV3);%0A%09%09Assert.assertEquals(mV3, e1.getToVertex());%0A%09%09e1 = new Edge(mV1, mV2);%0A%09%09Assert.assertEquals(mV2, e1.getToVertex());%0A%09%09e1 = new Edge(mV1, mV1);%0A%09%09Assert.assertEquals(mV1, e1.getToVertex());%0A%09%7D%0A%09%0A%09/**%0A%09 * tests the edge direction method%0A%09 */%0A%09public void testEdgeDirection() %7B%0A%09%09Edge e1 = new Edge(mV1, mV2);%0A%09%09Assert.assertEquals(false, e1.hasDirection());%0A%09%09e1 = new Edge(mV1, mV1);%0A%09%09Assert.assertEquals(false, e1.hasDirection());%0A%09%09e1 = new Edge(mV1, mV1, VertexDirection.fromTo);%0A%09%09Assert.assertEquals(true, e1.hasDirection());%0A%09%09e1 = new Edge(mV1, mV2, VertexDirection.fromTo);%0A%09%09Assert.assertEquals(true, e1.hasDirection());%0A%09%09e1 = new Edge(mV3, mV1, VertexDirection.toFrom);%0A%09%09Assert.assertEquals(true, e1.hasDirection());%0A%09%09e1 = new Edge(mV3, mV2, VertexDirection.toFrom);%0A%09%09Assert.assertEquals(true, e1.hasDirection());%0A%09%7D
 %0A%7D%0A

add some more tests for the new functions in edge