コード例 #1
0
  @Test
  public void all_valid_exits_are_retrieveable() {
    final Exit exit1 = mockery.mock(Exit.class, "exit1");
    final Exit exit2 = mockery.mock(Exit.class, "exit2");
    mockery.checking(
        new Expectations() {
          {
            allowing(exit1).visible();
            will(returnValue(true));
            ignoring(exit1);
            allowing(exit2).visible();
            will(returnValue(true));
            ignoring(exit2);
          }
        });
    List<Exit> exits = new ArrayList<Exit>();
    exits.add(exit1);
    exits.add(exit2);

    Location l = createLocation();
    l.addExit(exit1);
    l.addExit(exit2);

    assertEquals(exits, l.visibleExits());
  }
コード例 #2
0
 @Test
 public void non_visible_exits_are_not_in_the_exits_list() {
   final Exit exit = mockery.mock(Exit.class);
   mockery.checking(
       new Expectations() {
         {
           allowing(exit).visible();
           will(returnValue(false));
           ignoring(exit);
         }
       });
   Location l = createLocation();
   l.addExit(exit);
   assertEquals(0, l.visibleExits().size());
 }
コード例 #3
0
 @Test
 public void non_visible_exits_are_not_exitable() {
   final Exit exit = mockery.mock(Exit.class);
   mockery.checking(
       new Expectations() {
         {
           allowing(exit).visible();
           will(returnValue(false));
           ignoring(exit);
         }
       });
   Location l = createLocation();
   l.addExit(exit);
   assertFalse(l.exitable(exit));
 }
コード例 #4
0
 @Test
 public void added_exit_makes_the_exit_exitable() {
   final Exit exit = mockery.mock(Exit.class);
   mockery.checking(
       new Expectations() {
         {
           allowing(exit).visible();
           will(returnValue(true));
           ignoring(exit);
         }
       });
   Location l = createLocation();
   l.addExit(exit);
   assertTrue(l.exitable(exit));
 }