01: package net.sf.mockcreator;
02:
03: public class ClassWithToStringAndEqualsTest extends TestCase {
04: MockClassWithToStringAndEquals mock;
05:
06: public ClassWithToStringAndEqualsTest(String name) {
07: super (name);
08: }
09:
10: public void setUp() throws Exception {
11: super .setUp();
12: mock = new MockClassWithToStringAndEquals();
13: }
14:
15: public void testEquals() throws Exception {
16: // equals defined as return false
17: assertFalse(mock.equals(mock));
18: }
19:
20: public void testToString() throws Exception {
21: assertNull(mock.toString());
22: }
23:
24: public void testHashCode() throws Exception {
25: assertEquals(0, mock.hashCode());
26: }
27:
28: public void testEqualsMocks() throws Exception {
29: MockComplex c1 = new MockComplex();
30: MockComplex c2 = new MockComplex();
31: assertFalse(c1.equals(c2));
32: assertTrue(c1.equals(c1));
33: }
34:
35: public void testToStringMocks() throws Exception {
36: MockComplex c1 = new MockComplex();
37: assertTrue(c1.toString().startsWith(c1.getClass().getName()));
38: assertTrue(c1.toString().indexOf('@') > 0);
39: }
40: }
|