mockinvocationmatcher.java

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

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

import org.jmock.core.Invocation;
import org.jmock.core.InvocationMatcher;
import org.jmock.expectation.ExpectationValue;


public class MockInvocationMatcher
        extends MockVerifiable
        implements InvocationMatcher
{
    private String name;

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

    public MockInvocationMatcher() {
        this("mockInvocationMatcher");
    }

    public String toString() {
        return name;
    }


    public ExpectationValue matchesInvocation = new ExpectationValue("matches invocation");
    public boolean matchesResult = false;

    public boolean matches( Invocation invocation ) {
        matchesInvocation.setActual(invocation);
        return matchesResult;
    }

    public ExpectationValue invokedInvocation = new ExpectationValue("invoked invocation");

    public void invoked( Invocation invocation ) {
        invokedInvocation.setActual(invocation);
    }

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

    public boolean hasDescription() {
        return describeToOutput.length() > 0;
    }

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

⌨️ 快捷键说明

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