mockstub.java

来自「不管是测试驱动开发或者是其它的开发模式」· Java 代码 · 共 52 行

JAVA
52
字号
/*  Copyright (c) 2000-2004 jMock.org
 */
package test.jmock.core.testsupport;

import org.jmock.core.Invocation;
import org.jmock.core.Stub;
import org.jmock.core.Verifiable;
import org.jmock.expectation.ExpectationValue;
import org.jmock.util.Verifier;


public class MockStub
        implements Stub, Verifiable
{
    private String name;

    public MockStub() {
        this("mockStub");
    }

    public MockStub( String name ) {
        this.name = name;
    }

    public String toString() {
        return name;
    }

    public ExpectationValue invokeInvocation =
            new ExpectationValue("invoke invocation");
    public Object invokeResult;

    public Object invoke( Invocation invocation ) throws Throwable {
        invokeInvocation.setActual(invocation);
        return invokeResult;
    }


    public ExpectationValue describeToBuffer = new ExpectationValue("describeTo buffer");
    public String describeToOutput = "";

    public StringBuffer describeTo( StringBuffer buffer ) {
        describeToBuffer.setActual(buffer);
        buffer.append(describeToOutput);
        return buffer;
    }

    public void verify() {
        Verifier.verifyObject(this);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?