mockconstraint.java
来自「不管是测试驱动开发或者是其它的开发模式」· Java 代码 · 共 43 行
JAVA
43 行
/* Copyright (c) 2000-2004 jMock.org
*/
package test.jmock.core.testsupport;
import junit.framework.Assert;
import org.jmock.core.Constraint;
import org.jmock.core.Verifiable;
public class MockConstraint extends Assert implements Constraint, Verifiable
{
private String description;
private Object expectedArg;
private boolean result;
private boolean wasChecked = false;
public MockConstraint( String description ) {
this(description, null, true);
wasChecked = true;
}
public MockConstraint( String description, Object expectedArg, boolean result ) {
this.description = description;
this.expectedArg = expectedArg;
this.result = result;
}
public StringBuffer describeTo( StringBuffer buffer ) {
return buffer.append(description);
}
public boolean eval( Object arg ) {
assertSame("Should be expected argument", expectedArg, arg);
wasChecked = true;
return result;
}
public void verify() {
assertTrue(description + " should have been checked", wasChecked);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?