| 1 | /** |
| 2 | * Copyright (C) 2006 Carrier Access, Corp. |
| 3 | */ |
| 4 | package biz.xsoftware.mock.client.test; |
| 5 | |
| 6 | import biz.xsoftware.mock.client.JsCalledMethod; |
| 7 | |
| 8 | import com.google.gwt.junit.client.GWTTestCase; |
| 9 | |
| 10 | /** |
| 11 | */ |
| 12 | public class TestMocking extends GWTTestCase |
| 13 | { |
| 14 | |
| 15 | /** |
| 16 | * @see com.google.gwt.junit.client.GWTTestCase#getModuleName() |
| 17 | */ |
| 18 | public String getModuleName() |
| 19 | { |
| 20 | return "biz.xsoftware.mock.MockLib"; |
| 21 | } |
| 22 | |
| 23 | public void testBasicMock() { |
| 24 | MockFakeInterface mock = new MockFakeInterface(); |
| 25 | |
| 26 | String val = "Aasfd"; |
| 27 | int val2 = 5; |
| 28 | mock.someMethod(val, val2); |
| 29 | |
| 30 | JsCalledMethod m = mock.expect(MockFakeInterface.SOME_METHOD); |
| 31 | String actualVal = (String)m.getAllParams()[0]; |
| 32 | Integer actualVal2 = (Integer)m.getAllParams()[1]; |
| 33 | |
| 34 | assertEquals(val, actualVal); |
| 35 | assertEquals(val2, actualVal2.intValue()); |
| 36 | } |
| 37 | |
| 38 | public void testReturnValue() { |
| 39 | MockFakeInterface mock = new MockFakeInterface(); |
| 40 | |
| 41 | int expectedVal = 5; |
| 42 | mock.addReturnValue(MockFakeInterface.GET_VALUE, new Integer(expectedVal)); |
| 43 | |
| 44 | int actualVal = mock.getValue(); |
| 45 | assertEquals(expectedVal, actualVal); |
| 46 | } |
| 47 | } |