Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects
In directory usw-pr-cvs1:/tmp/cvs-serv20384/src/core/com/mockobjects
Modified Files:
ReturnObjectList.java
Log Message:
Add test and docs for ReturnObjectList
Index: ReturnObjectList.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ReturnObjectList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReturnObjectList.java 22 Apr 2002 16:39:31 -0000 1.1
+++ ReturnObjectList.java 23 Apr 2002 11:09:59 -0000 1.2
@@ -4,29 +4,54 @@
import java.util.Vector;
+/**
+ * <p>This class allows a list of objects to be setup which can be used whilst.The
+ * list is check to make sure that all the object in it are used and that none
+ * are left over at the end of a test.</p>
+ *
+ * <p>For ever sucessive call to nextReturnObject the next object in the list will
+ * returned.</p>
+ *
+ * <p>If the nextReturnObject method is called and there are no objects in the list
+ * an assertion error will be thrown. If the verify method is called and there
+ * are objects still in the list an assertion error will also be thrown.</p>
+ */
public class ReturnObjectList implements Verifiable {
private final Vector myObjects = new Vector();
private final String myName;
+ /**
+ * Construct a new empty list
+ * @param aName Label used to identify list
+ */
public ReturnObjectList(String aName) {
this.myName = aName;
}
+ /**
+ * Add a next object to the end of the list.
+ * @param anOjectToReturn object to be added to the list
+ */
public void addObjectToReturn(Object anObjectToReturn){
myObjects.add(anObjectToReturn);
}
+ /**
+ * Returns the next object from the list. Each object it returned in the
+ * order in which they where added.
+ */
public Object nextReturnObject(){
- if(myObjects.size()>0){
- return myObjects.remove(0);
- }else{
- AssertMo.fail(myName + " has run out of objects.");
- return null;
- }
+ AssertMo.assertTrue(myName + " has run out of objects.",
+ myObjects.size() > 0);
+ return myObjects.remove(0);
}
+ /**
+ * Verify that there are no objects left within the list.
+ */
public void verify() {
- AssertMo.assertEquals(myName + " has un-used objects.", 0, myObjects.size());
+ AssertMo.assertEquals(myName + " has un-used objects.", 0,
+ myObjects.size());
}
}
|