01: package net.sf.mockcreator;
02:
03: public class DuplicatesTest extends TestCase {
04: MockDuplicates mock;
05:
06: public DuplicatesTest(String name) {
07: super (name);
08: }
09:
10: public void setUp() throws Exception {
11: super .setUp();
12: mock = new MockDuplicates();
13: }
14:
15: public void testDummy() {
16: mock.expectZeroOrMoreMethod_int_returning_int().throwable(
17: new IllegalArgumentException());
18: mock.expectZeroOrMoreMethod(555).returns(777);
19:
20: mock.expectZeroOrMoreMethod_int_int_returning_int().throwable(
21: new IllegalStateException());
22: mock.expectZeroOrMoreMethod(555, 777).returns(888);
23:
24: mock.expectZeroOrMoreMethod_boolean_returning_int().throwable(
25: new ClassCastException());
26: mock.expectZeroOrMoreMethod(false).returns(999);
27:
28: try {
29: mock.method(100);
30: fail();
31: } catch (IllegalArgumentException ex) {
32: }
33:
34: assertEquals(777, mock.method(555));
35:
36: try {
37: mock.method(100, 200);
38: fail();
39: } catch (IllegalStateException ex) {
40: }
41:
42: assertEquals(888, mock.method(555, 777));
43:
44: try {
45: mock.method(true);
46: fail();
47: } catch (ClassCastException ex) {
48: }
49:
50: assertEquals(999, mock.method(false));
51: }
52:
53: public void testAccept() {
54: mock.acceptMethod_int_returning_int(new Integer(333))
55: .returns(4);
56: mock.acceptMethod(new Integer(333), new Integer(334))
57: .returns(5);
58: mock.acceptMethod_boolean_returning_int(new Boolean(true))
59: .returns(6);
60:
61: assertEquals(4, mock.method(333));
62: assertEquals(5, mock.method(333, 334));
63: assertEquals(6, mock.method(true));
64: MockCore.verify();
65: }
66: }
|