From: Jeff M. <cus...@us...> - 2003-08-11 09:16:46
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv19045/src/core/test/mockobjects Added Files: TestReturnObjectMap.java Log Message: Added Return map --- NEW FILE: TestReturnObjectMap.java --- package test.mockobjects; import com.mockobjects.ReturnObjectMap; import com.mockobjects.util.TestCaseMo; import junit.framework.AssertionFailedError; public class TestReturnObjectMap extends TestCaseMo { private final ReturnObjectMap map = new ReturnObjectMap(getName()); private static final String KEY1 = "key1"; private static final String KEY2 = "key2"; private static final short SHORT_KEY1 = 1; private static final short SHORT_KEY2 = 2; private static final String VALUE_ONE = "one"; private static final String VALUE_TWO = "two"; public TestReturnObjectMap(String name) { super(name); } public static void main(String[] args) { start(new String[] { TestReturnObjectMap.class.getName()}); } public void testLeftoverObjectFails() { map.putReturnValue(KEY1, VALUE_ONE); assertVerifyFails(map); } public void testEmptyList() { map.verify(); } public void testReturnSucceeds() { map.putReturnValue(KEY1, VALUE_ONE); map.putReturnValue(KEY2, VALUE_TWO); assertEquals("Should be first result", VALUE_ONE, map.getValue(KEY1)); assertEquals("Should be second result", VALUE_TWO, map.getValue(KEY2)); map.verify(); } public void testReturnInt() { map.putReturnValue(KEY1, 1); assertEquals("Should be 1", 1, map.getIntValue(KEY1)); map.verify(); } public void testReturnBoolean() { map.putReturnValue(KEY1, true); assertEquals("Should be true", true, map.getBooleanValue(KEY1)); map.verify(); } public void testShortKey(){ map.putReturnValue(SHORT_KEY1, VALUE_ONE); map.putReturnValue(SHORT_KEY2, VALUE_TWO); assertEquals("Should be first result", VALUE_ONE, map.getValue(SHORT_KEY1)); assertEquals("Should be second result", VALUE_TWO, map.getValue(SHORT_KEY2)); map.verify(); } public void testNoListForKey(){ try { map.getValue(KEY1); fail("AssertionFiledError not thrown"); } catch (AssertionFailedError e) { assertEquals(getName() + " does not contain key1", e.getMessage()); } } public void testNullKey(){ map.putReturnValue(null, VALUE_ONE); assertEquals(VALUE_ONE, map.getValue(null)); } public void testManyReturns() { map.putReturnValue(KEY1, VALUE_ONE); assertEquals(map.getValue(KEY1),map.getValue(KEY1)); } } |