All pastes #810711 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-10 05:05 UTC
rendered paste body
package model;

import junit.framework.TestCase;
import java.util.Random;

//import model.AngryFink;
//import model.PeacefullFink;


public class testFink extends junit.framework.TestCase {


			// instance variables:
			private Fink tinoTest;
			private Fink otherFink;
			private Random random;
		

			// test set up: called every time before executing a test method
			protected void setUp () {
				//Random random = this.random;
			tinoTest = new AngryFink("Tino", 2, random );
			otherFink= new PeacefullFink("TheThing", 2, random);
			}

			// Testing death by age, Fink being alive and well, statechange
			public void testClass () {
				setUp();
				tinoTest.birthday();
			assertTrue( "Tino is alive", tinoTest.alive() == true);
			tinoTest.birthday();
			tinoTest.birthday();
			assertTrue( "Tino is Dead", tinoTest.alive() == false);
			
			
			// Testing death by loss of energy and testing removeenergy
			setUp();
			tinoTest.removeEnergy(15);
			assertTrue( "Tino is alive", tinoTest.alive() == true);
			tinoTest.removeEnergy(15);
			assertTrue( "Tino is dead", tinoTest.alive() == false);
			
			// Testing addenergy
			setUp();
			tinoTest.addEnergy(10);
			assertEquals(30, tinoTest.energy());
			
			setUp();
			tinoTest.prune(otherFink);
			//assertTrue( "I pruned other", tinoTest.lastPruned() == false);
			}
			
			
}