01: package net.sf.mockcreator.expectable;
02:
03: import net.sf.mockcreator.TestCase;
04: import net.sf.mockcreator.exceptions.MockException;
05:
06: public class ExpectableExpectSameTest extends TestCase {
07: MockExpectableExpectSame mock;
08:
09: public ExpectableExpectSameTest(String name) {
10: super (name);
11: }
12:
13: public void setUp() throws Exception {
14: super .setUp();
15: mock = new MockExpectableExpectSame();
16: }
17:
18: public void testSwap() {
19: ExpectSame s1 = new ExpectSame();
20: ExpectSame s2 = new ExpectSame();
21: mock.acceptFoo(s1, s2);
22: mock.acceptFoo(s2, s1);
23:
24: ExpectableExpectSame.Runner.doSwap(mock);
25: }
26:
27: public void testUnswapped() {
28: ExpectSame s1 = new ExpectSame();
29: ExpectSame s2 = new ExpectSame();
30: mock.acceptFoo(s1, s2);
31: mock.acceptFoo(s1, s2);
32:
33: try {
34: ExpectableExpectSame.Runner.doSwap(mock);
35: fail();
36: } catch (MockException ex) {
37: }
38: }
39:
40: public void testSwapPtrs() {
41: ExpectSame s1 = new ExpectSame();
42: ExpectSame s2 = new ExpectSame();
43: mock.acceptFoo(s1, s2);
44: mock.acceptFoo(s2, s1);
45:
46: ExpectableExpectSame.Runner.doSwapPtrs(mock);
47: }
48:
49: public void testUnswappedPtrs() {
50: ExpectSame s1 = new ExpectSame();
51: ExpectSame s2 = new ExpectSame();
52: mock.acceptFoo(s1, s2);
53: mock.acceptFoo(s1, s2);
54:
55: try {
56: ExpectableExpectSame.Runner.doSwapPtrs(mock);
57: fail();
58: } catch (MockException ex) {
59: }
60: }
61:
62: public void testSwapInts() {
63: ExpectSame s1 = new ExpectSame();
64: ExpectSame s2 = new ExpectSame();
65: mock.acceptBar(s1, s2);
66: mock.acceptBar(s2, s1);
67:
68: ExpectableExpectSame.Runner.doSwapInts(mock);
69: }
70:
71: public void testUnswappedInts() {
72: ExpectSame s1 = new ExpectSame();
73: ExpectSame s2 = new ExpectSame();
74: mock.acceptBar(s1, s2);
75: mock.acceptBar(s1, s2);
76:
77: try {
78: ExpectableExpectSame.Runner.doSwapInts(mock);
79: fail();
80: } catch (MockException ex) {
81: }
82: }
83: }
|