KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > mockobjects > dynamic > MockConstraint


1 /*
2  * Created on 04-Apr-2003
3  */

4 package test.mockobjects.dynamic;
5
6 import junit.framework.*;
7
8 import com.mockobjects.*;
9 import com.mockobjects.constraint.*;
10
11 /**
12  * @author dev
13  */

14 public class MockConstraint extends Assert implements Constraint, Verifiable {
15     private String JavaDoc description;
16     private Object JavaDoc expectedArg;
17     private boolean result;
18     private boolean wasChecked = false;
19     
20     public MockConstraint( String JavaDoc description, Object JavaDoc expectedArg, boolean result ) {
21         this.description = description;
22         this.expectedArg = expectedArg;
23         this.result = result;
24     }
25
26     public String JavaDoc toString() {
27         return description;
28     }
29     
30     public boolean eval( Object JavaDoc 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