cs1705
Class TestableWorld

java.lang.Object
  extended bycs1705.TestableWorld
Direct Known Subclasses:
World

public class TestableWorld
extends Object

This class provides the basic assertion capabilities for Karel's World in the form of methods useful for writing test cases. Consider using World instead of referring to this class directly.

Note that, although this class cannot be directly instantiated, all of its methods are non-static. That is because these assertions were designed for use with BlueJ's JUnit support. You can use World.getWorldAsObject() or TestableRobot.getWorldAsObject() to get a reference to a unique global instance of the world object, and then call these methods on it directly.

Version:
2003.08.20
Author:
Stephen Edwards

Constructor Summary
TestableWorld()
          This class should not be instantiated--it only provides static methods that can be called without an object.
 
Method Summary
 void assertBeepersAt(int street, int avenue)
          Fail if there are no beepers at the given intersection.
 void assertBeepersAt(int street, int avenue, int count)
          Fail if the number of beepers at the given intersection is different than the specified count.
 void assertBeepersInWorld()
          Fail if there are no beepers anywhere in this world.
 void assertBeepersInWorld(int count)
          Fail if the total number of beepers in this world, regardless of their location, is different than the specified count.
 void assertEWWallAt(int northOfStreet, int crossingAvenue)
          Fail if there is no east/west wall at the given location.
 void assertNoBeepersAt(int street, int avenue)
          Fail if there is at least one beeper at the given intersection.
 void assertNoBeepersInWorld()
          Fail if there are any beepers anywhere in this world.
 void assertNoEWWallAt(int northOfStreet, int crossingAvenue)
          Fail if there is an east/west wall at the given intersection.
 void assertNoNSWallAt(int crossingStreet, int eastOfAvenue)
          Fail if there is a north/south wall at the given location.
 void assertNoRobotsInWorld()
          Fail if there are any robots anywhere in this world.
 void assertNSWallAt(int crossingStreet, int eastOfAvenue)
          Fail if there is no north/south wall at the given location.
 void assertRobotsInWorld()
          Fail if there are no robots anywhere in this world.
 void assertRobotsInWorld(int count)
          Fail if the total number of robots in this world, regardless of their location, is different than the specified count.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestableWorld

public TestableWorld()
This class should not be instantiated--it only provides static methods that can be called without an object. The constructor is protected to allow subclassing.

Method Detail

assertBeepersAt

public void assertBeepersAt(int street,
                            int avenue)
Fail if there are no beepers at the given intersection. No-op otherwise.

Parameters:
street - the street number to check at
avenue - the avenue number to check at

assertBeepersAt

public void assertBeepersAt(int street,
                            int avenue,
                            int count)
Fail if the number of beepers at the given intersection is different than the specified count. No-op otherwise.

Parameters:
street - the street number to check at
avenue - the avenue number to check at
count - the number of beepers to check for

assertBeepersInWorld

public void assertBeepersInWorld()
Fail if there are no beepers anywhere in this world. No-op otherwise.


assertBeepersInWorld

public void assertBeepersInWorld(int count)
Fail if the total number of beepers in this world, regardless of their location, is different than the specified count. No-op otherwise. Note that if any beeper pile countains an infinite number of beepers, that will only match a count of Directions.infinity (-1).

Parameters:
count - the number of beepers expected

assertEWWallAt

public void assertEWWallAt(int northOfStreet,
                           int crossingAvenue)
Fail if there is no east/west wall at the given location. No-op otherwise.

Parameters:
northOfStreet - the street number to check at
crossingAvenue - the avenue number to check at

assertNoBeepersAt

public void assertNoBeepersAt(int street,
                              int avenue)
Fail if there is at least one beeper at the given intersection. No-op otherwise.

Parameters:
street - the street number to check at
avenue - the avenue number to check at

assertNoBeepersInWorld

public void assertNoBeepersInWorld()
Fail if there are any beepers anywhere in this world. No-op otherwise.


assertNoEWWallAt

public void assertNoEWWallAt(int northOfStreet,
                             int crossingAvenue)
Fail if there is an east/west wall at the given intersection. No-op otherwise.

Parameters:
northOfStreet - the street number to check at
crossingAvenue - the avenue number to check at

assertNoNSWallAt

public void assertNoNSWallAt(int crossingStreet,
                             int eastOfAvenue)
Fail if there is a north/south wall at the given location. No-op otherwise.

Parameters:
crossingStreet - the street number to check at
eastOfAvenue - the avenue number to check at

assertNoRobotsInWorld

public void assertNoRobotsInWorld()
Fail if there are any robots anywhere in this world. No-op otherwise.


assertNSWallAt

public void assertNSWallAt(int crossingStreet,
                           int eastOfAvenue)
Fail if there is no north/south wall at the given location. No-op otherwise.

Parameters:
crossingStreet - the street number to check at
eastOfAvenue - the avenue number to check at

assertRobotsInWorld

public void assertRobotsInWorld()
Fail if there are no robots anywhere in this world. No-op otherwise.


assertRobotsInWorld

public void assertRobotsInWorld(int count)
Fail if the total number of robots in this world, regardless of their location, is different than the specified count. No-op otherwise.

Parameters:
count - the number of robots expected