package edu.wheaton.simulator.test.datastructure;

import static org.junit.Assert.*;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import edu.wheaton.simulator.datastructure.Field;

public class FieldTest {

	private Field field;
	
	@Before
	public void setUp() {
		
	}
	
	@Test
	public void testString() {
		field = new Field("name", "rabbit");
		
		Assert.assertEquals(field.getName(), "name");
		Assert.assertEquals(field.getValue(), "rabbit");
//		
////		try {
////			field.getBoolValue();
////			fail("We got a boolean value from a nonsensical string: " + field.getBoolValue());
////		}
////		catch (Exception e) {
////			
////		}
//		
		try {
			field.getDoubleValue();
			fail("We got a double value from a nonsensical string: " + field.getDoubleValue());
		}
		catch (Exception e) {
			
		}
		
		try {
			field.getIntValue();
			fail("We got an int value from a nonsensical string: " + field.getIntValue());
		}
		catch (Exception e) {
			
		}
	}
	
	@Test
	public void testDouble() {
		field = new Field("percentBodyWeight", "0.221");
		
		//no need to test string name and value (see testString)
		
		try {
			field.getBoolValue();
			fail("We got a boolean value from a nonsensical string: " + field.getBoolValue());
		}
		catch (Exception e) {
			
		}
		
		try {
			field.getDoubleValue();
		}
		catch (Exception e) {
			fail("We could not obtain a double representation of the value: " + field.getDoubleValue());
		}
		
		try {
			field.getIntValue();
			fail("We got an int value from a nonsensical string: " + field.getIntValue());
		}
		catch (Exception e) {
			
		}
	}
	
	@Test
	public void testInt() {
		field = new Field("xPos", "13");
		
		try {
			field.getBoolValue();
			fail("We got a boolean value from a nonsensical string: " + field.getBoolValue());
		}
		catch (Exception e) {
			
		}
		
		try {
			field.getDoubleValue();
		}
		catch (Exception e) {
			fail("We could not obtain a double representation of the value: " + field.getDoubleValue());
		}
		
		try {
			field.getIntValue();
		}
		catch (Exception e) {
			fail("We could not obtain an int representation of the value: " + field.getIntValue());
		}
	}

	@Test
	public void testBoolean() {
		field = new Field("isFemale", "true");
		
		try {
			field.getBoolValue();
		}
		catch (Exception e) {
			fail("We could not obtain a boolean representation of the value.");
		}
		
		try {
			field.getDoubleValue();
			fail("We got a double value from a nonsensical string: " + field.getDoubleValue());
		}
		catch (Exception e) {
			
		}
		
		try {
			field.getIntValue();
			fail("We got an int value from a nonsensical string: " + field.getIntValue());
		}
		catch (Exception e) {
			
		}
	}
}

@@ -499,208 +499,8 @@
 );%0D%0A
-//%09%09%0D%0A////%09%09try %7B%0D%0A////%09%09%09field.getBoolValue();%0D%0A////%09%09%09fail(%22We got a boolean value from a nonsensical string: %22 + field.getBoolValue());%0D%0A////%09%09%7D%0D%0A////%09%09catch (Exception e) %7B%0D%0A////%09%09%09%0D%0A////%09%09%7D%0D%0A//%09%09
 %0D%0A%09%09
@@ -929,248 +929,50 @@
 %0D%0A%09%09
-//no need to test string name and value (see testString)%0D%0A%09%09%0D%0A%09%09try %7B%0D%0A%09%09%09field.getBoolValue();%0D%0A%09%09%09fail(%22We got a boolean value from a nonsensical string: %22 + field.getBoolValue());%0D%0A%09%09%7D%0D%0A%09%09catch (Exception e) %7B%0D%0A%09%09%09%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09try %7B%0D%0A%09%09%09
+try %7B%0D%0A%09%09%09Assert.assertEquals(0.221 + %22%22, 
 fiel
@@ -981,32 +981,38 @@
 getDoubleValue()
+ + %22%22)
 ;%0D%0A%09%09%7D%0D%0A%09%09catch 
@@ -1139,596 +1139,129 @@
 %09%0D%0A%09
-%09try %7B%0D%0A%09%09%09field.getIntValue();%0D%0A%09%09%09fail(%22We got an int value from a nonsensical string: %22 + field.getIntValue());%0D%0A%09%09%7D%0D%0A%09%09catch (Exception e) %7B%0D%0A%09%09%09%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test%0D%0A%09public void testInt() %7B%0D%0A%09%09field = new Field(%22xPos%22, %2213%22);%0D%0A%09%09%0D%0A%09%09try %7B%0D%0A%09%09%09field.getBoolValue();%0D%0A%09%09%09fail(%22We got a boolean value from a nonsensical string: %22 + field.getBoolValue());%0D%0A%09%09%7D%0D%0A%09%09catch (Exception e) %7B%0D%0A%09%09%09%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09try %7B%0D%0A%09%09%09field.getDoubleValue();%0D%0A%09%09%7D%0D%0A%09%09catch (Exception e) %7B%0D%0A%09%09%09fail(%22We could not obtain a double representation of the value: %22 + field.getDoubleValue());%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09try %7B%0D%0A%09%09%09
+%7D%0D%0A%09%0D%0A%09@Test%0D%0A%09public void testInt() %7B%0D%0A%09%09field = new Field(%22xPos%22, %2213%22);%0D%0A%09%09%0D%0A%09%09try %7B%0D%0A%09%09%09Assert.assertEquals(13 + %22%22, 
 fiel
@@ -1271,24 +1271,30 @@
 etIntValue()
+ + %22%22)
 ;%0D%0A%09%09%7D%0D%0A%09%09ca

Fix issues with Field JUnit test