1 package test.mockobjects; 2 3 import com.mockobjects.ExpectationSet; 4 import com.mockobjects.MapEntry; 5 import junit.framework.Test; 6 import junit.framework.TestSuite; 7 8 import java.util.ArrayList ; 9 import java.util.Vector ; 10 11 public class TestExpectationSet extends TestExpectationCollection { 12 private static final Class THIS = TestExpectationSet.class; 13 14 public TestExpectationSet(String name) { 15 super(name); 16 myExpectation = new ExpectationSet(name); 17 } 18 19 public void lookAtTheSuperclassForTests() { 20 } 21 22 public static void main(String [] args) { 23 start(new String [] { THIS.getName()}); 24 } 25 26 public static Test suite() { 27 return new TestSuite(THIS); 28 } 29 30 public void testMultiUnsorted() { 31 myExpectation.addExpectedMany(new String [] { "A", "B" }); 32 33 myExpectation.addActualMany(new String [] { "A", "B" }); 34 35 myExpectation.verify(); 36 } 37 38 public void testChangingHashcode() { 39 final Vector value = new Vector (); 40 41 myExpectation.addExpected(new MapEntry("key", value)); 42 myExpectation.addActual(new MapEntry("key", value)); 43 44 value.add(getName()); 45 46 myExpectation.verify(); 47 } 48 49 public void testChanginHashcodeImediateCheck() { 50 final Vector value = new Vector (); 51 52 myExpectation.addExpected(new MapEntry("key", value)); 53 value.add(getName()); 54 myExpectation.addActual(new MapEntry("key", value)); 55 56 myExpectation.verify(); 57 } 58 59 public void testMultiUnsortedSet() { 60 myExpectation.addExpectedMany(new String [] { "A", "B" }); 61 62 myExpectation.addActualMany(new String [] { "A", "B", "A", "B" }); 63 64 myExpectation.verify(); 65 } 66 67 public void testUnsorted() { 68 myExpectation.addExpected("A"); 69 myExpectation.addExpected("B"); 70 71 myExpectation.addActual("B"); 72 myExpectation.addActual("A"); 73 74 myExpectation.verify(); 75 } 76 77 public void testUnsortedSet() { 78 myExpectation.addExpected("A"); 79 myExpectation.addExpected("B"); 80 81 myExpectation.addActual("A"); 82 myExpectation.addActual("B"); 83 myExpectation.addActual("A"); 84 myExpectation.addActual("B"); 85 86 myExpectation.verify(); 87 } 88 } 89 | Popular Tags |