/*
	MatheTest.java

	Setup:
$ javac -classpath %JUNIT_PATH%/junit.jar;. MatheTest.java
$ java -classpath %JUNIT_PATH%/junit.jar;. junit.textui.TestRunner MatheTest
	or
$ java -classpath %JUNIT_PATH%/junit.jar;. junit.swingui.TestRunner MatheTest

*/

import junit.framework.*;

public class MatheTest extends TestCase {
	Mathe m;

	public static void main(String args[]){
		junit.textui.TestRunner.run(suite());
	}

	public static Test suite(){
		return new TestSuite(MatheTest.class);
/*
		To specify the order in which the tests should be run, you may use a
		method like this one:
		
		TestSuite suite = new TestSuite(MatheTest.class);
		TestSuite suite = new TestSuite();
		suite.addTest(new MatheTest("testOdd"));
		suite.addTest(new MatheTest("testFakultaet"));
		suite.addTest(new MatheTest("testMWSt"));
		return suite;
*/
	}

	protected void setUp(){
		m = new Mathe();
	}

	protected void tearDown(){
		// nothing to do here
	}
	
	/*
		All of the tests below uses methods like
		
		assertEquals(msg, expected_value, actual_value);
		assertEquals(msg, expected_value, actual_value ,delta); // float and double
		assertTrue(msg, actual_value);
		assertFalse(msg, actual_value);
	*/
	public void testFakultaet(){
		assertEquals("0! should be 1!", 1, m.fak(0));
		assertEquals("1! should be 1!", 1, m.fak(1));
		assertEquals("2! should be 2!", 2, m.fak(2));
		assertEquals("3! should be 6!", 6, m.fak(3));
	}

	public void testMWSt(){
		assertEquals("MWSt of 100 should be 16!", 16.0, m.MWSt(100.), 0.001);
		assertEquals("MESt of 1 should be 0.16!", 0.16, m.MWSt(1.), 0.001);
	}
	
	public void testOdd(){
		assertFalse("0 should not be odd!", m.isOdd(0));
		assertTrue("1 should be odd!", m.isOdd(1));
		assertFalse("2 should not be odd!", m.isOdd(2));
	}
}

