1 4 package test.mockobjects.dynamic; 5 6 import com.mockobjects.dynamic.DynamicUtil; 7 import com.mockobjects.dynamic.Mock; 8 import com.mockobjects.util.AssertMo; 9 10 import junit.framework.TestCase; 11 12 15 public class DynamicUtilTest extends TestCase { 16 17 public DynamicUtilTest(String name) { 18 super(name); 19 } 20 21 public void testMethodToStringWithoutProxyArg() throws Exception { 22 String [] args = new String [] {"arg1", "arg2" }; 23 24 String result = DynamicUtil.methodToString("methodName", args); 25 26 AssertMo.assertIncludes("Should contain method name", "methodName", result); 27 AssertMo.assertIncludes("Should contain firstArg", "arg1", result); 28 AssertMo.assertIncludes("Should contain second Arg", "arg2", result); 29 } 30 31 public void testMethodToStringWithStringArray() throws Exception { 32 Object [] args = new Object [] { new String [] {"arg1","arg2"}}; 33 34 String result = DynamicUtil.methodToString("methodName", args); 35 36 AssertMo.assertIncludes("Should contain method name", "methodName", result); 37 AssertMo.assertIncludes("Should contain args as an array", "[<arg1>, <arg2>]", result); 38 } 39 40 public void testMethodToStringWithPrimitiveArray() throws Exception { 41 Object [] args = new Object [] { new long[] {1,2}}; 42 43 String result = DynamicUtil.methodToString("methodName", args); 44 45 AssertMo.assertIncludes("Should contain method name", "methodName", result); 46 AssertMo.assertIncludes("Should contain args as an array", "[<1>, <2>]", result); 47 } 48 49 public void testMethodToStringWithProxyArg() throws Exception { 50 Mock mockDummyInterface = new Mock(DummyInterface.class, "DummyMock"); 51 Object [] args = new Object [] {"arg1", mockDummyInterface.proxy()}; 52 53 String result = DynamicUtil.methodToString("methodName", args); 54 55 AssertMo.assertIncludes("Should contain method name", "methodName", result); 56 AssertMo.assertIncludes("Should contain firstArg", "arg1", result); 57 AssertMo.assertIncludes("Should contain second Arg", "DummyMock", result); 58 } 59 60 } 61 | Popular Tags |