1 4 package test.mockobjects.dynamic; 5 6 import junit.framework.*; 7 8 import com.mockobjects.*; 9 import com.mockobjects.constraint.*; 10 11 14 public class MockConstraint extends Assert implements Constraint, Verifiable { 15 private String description; 16 private Object expectedArg; 17 private boolean result; 18 private boolean wasChecked = false; 19 20 public MockConstraint( String description, Object expectedArg, boolean result ) { 21 this.description = description; 22 this.expectedArg = expectedArg; 23 this.result = result; 24 } 25 26 public String toString() { 27 return description; 28 } 29 30 public boolean eval( Object arg ) { 31 assertSame( "Should be expected argument", expectedArg, arg ); 32 wasChecked = true; 33 return result; 34 } 35 36 public void verify() { 37 assertTrue( description + " should have been checked", wasChecked ); 38 } 39 } 40 | Popular Tags |