expectationlist.java

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

JAVA
42
字号
/*  Copyright (c) 2000-2004 jMock.org
 */
package org.jmock.expectation;

import java.util.ArrayList;
import java.util.Collection;
import junit.framework.Assert;


public class ExpectationList extends AbstractExpectationCollection
{
    protected ArrayList myExpectedItems = new ArrayList();
    protected ArrayList myActualItems = new ArrayList();

    public ExpectationList( String name ) {
        super(name);
    }

    protected void checkImmediateValues( Object actualItem ) {
        int size = myActualItems.size();
        Assert.assertTrue(myName
                          + " had different sizes\nExpected Size:"
                          + myExpectedItems.size()
                          + "\nReceived size: "
                          + size
                          + " when adding:"
                          + actualItem,
                          myExpectedItems.size() >= size);
        assertEquals(myName + " added item does not match",
                     myExpectedItems.get(size - 1),
                     actualItem);
    }

    protected Collection getActualCollection() {
        return myActualItems;
    }

    protected Collection getExpectedCollection() {
        return myExpectedItems;
    }
}

⌨️ 快捷键说明

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