01: package net.sf.mockcreator.expectable;
02:
03: import net.sf.mockcreator.TestCase;
04: import net.sf.mockcreator.expectable.ExpectSame;
05:
06: public class ExpectSameTest extends TestCase {
07:
08: public ExpectSameTest(String name) {
09: super (name);
10: }
11:
12: public void testBasic() {
13: ExpectSame es = new ExpectSame();
14:
15: assertTrue(es.isExpected("Foo"));
16: assertTrue(es.isExpected("Foo"));
17: assertTrue(es.isExpected("Foo"));
18: }
19:
20: public void testBasicFail() {
21: ExpectSame es = new ExpectSame();
22:
23: assertTrue(es.isExpected("Foo"));
24: assertTrue(es.isExpected("Foo"));
25: assertFalse(es.isExpected("Bar"));
26: assertFalse(es.isExpected(null));
27: }
28:
29: public void testCompareByValue() {
30: ExpectSame es = new ExpectSame();
31:
32: String f1 = "Foo";
33: String f2 = "F" + f1.substring(1, 2) + "o";
34: assertFalse(f1 == f2);
35:
36: assertTrue(es.isExpected(f1));
37: assertTrue(es.isExpected(f2));
38: }
39:
40: public void testDifferentTypes() {
41: ExpectSame es = new ExpectSame();
42:
43: assertTrue(es.isExpected(new Long(1)));
44: assertTrue(es.isExpected(new Long(1)));
45: assertFalse(es.isExpected(new Integer(1)));
46: }
47:
48: public void testSameNull() {
49: ExpectSame es = new ExpectSame();
50:
51: assertTrue(es.isExpected(null));
52: assertTrue(es.isExpected(null));
53: assertFalse(es.isExpected("Foo"));
54: assertTrue(es.isExpected(null));
55: }
56: }
|