示例#1
0
 @Test
 public void hasItemFindsItem() {
   Item item = getRegularItem();
   assertFalse(inventory.hasItem(item));
   inventory.executeAddItem(InventorySlot.ARMOR, item);
   assertTrue(inventory.hasItem(item));
 }
示例#2
0
 @Test
 public void executeRemoveItemRemovesItem() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.ARMOR, item);
   inventory.executeRemoveItem(item);
   assertTrue(inventory.isEmpty(InventorySlot.ARMOR));
 }
示例#3
0
 @Test
 public void providesSlotLocation() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.HEAD, item);
   ItemLocation loc = inventory.getSlotLocation(InventorySlot.HEAD);
   assertNotNull(loc);
   assertSame(item, loc.get());
 }
示例#4
0
 @Test
 public void locationOfItemFindsItem() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.HEAD, item);
   ItemLocation loc = inventory.getLocationOf(item);
   assertNotNull(loc);
   assertSame(item, loc.get());
   assertEquals(InventorySlot.HEAD.ordinal(), loc.getIndex());
   assertSame(inventory, loc.getCylinder());
 }
示例#5
0
 @Test
 public void queryAddItemRequiresEmptySlot() {
   inventory.executeAddItem(InventorySlot.LEFT, getRegularItem());
   Item item =
       createItem(
           new ItemType() {
             {
               attributes = EnumSet.of(PICKUPABLE);
             }
           });
   assertEquals(ErrorType.NOTENOUGHROOM, inventory.queryAddItem(InventorySlot.LEFT, item));
 }
示例#6
0
 @Test
 public void contentsSpectatorsIsPlayer() {
   Spectators<Creature> s = inventory.getContentsSpectators(Creature.class);
   Iterator<Creature> it = s.iterator();
   assertTrue(it.hasNext());
   assertSame(player, it.next());
   assertFalse(it.hasNext());
 }
示例#7
0
 @Test
 public void queryAddItemValid() {
   Item item =
       createItem(
           new ItemType() {
             {
               attributes = EnumSet.of(PICKUPABLE);
             }
           });
   assertEquals(ErrorType.NONE, inventory.queryAddItem(InventorySlot.LEFT, item));
 }
示例#8
0
 @Test
 public void placementIsPlayerPlacement() {
   context.checking(
       new Expectations() {
         {
           allowing(player).isPlaced();
           will(returnValue(true));
         }
       });
   assertTrue(inventory.isPlaced());
 }
示例#9
0
 @Test
 public void queryAddItemRequiresFit() {
   Item item =
       createItem(
           new ItemType() {
             {
               attributes = EnumSet.of(PICKUPABLE);
               slots = EnumSet.complementOf(EnumSet.of(InventorySlot.HEAD));
             }
           });
   assertEquals(ErrorType.DOESNOTFIT, inventory.queryAddItem(InventorySlot.HEAD, item));
 }
示例#10
0
 @Test
 public void tileIsPlayerTile() {
   final Tile tile = context.mock(Tile.class);
   context.checking(
       new Expectations() {
         {
           allowing(player).getTile();
           will(returnValue(tile));
         }
       });
   assertSame(tile, inventory.getTile());
 }
示例#11
0
 @Test
 public void parentIsPlayerParent() {
   final Cylinder parent = context.mock(Cylinder.class);
   context.checking(
       new Expectations() {
         {
           allowing(player).getParent();
           will(returnValue(parent));
         }
       });
   assertSame(parent, inventory.getParent());
 }
示例#12
0
 @Test
 public void queryRemoveItemBySlotRequiresItem() {
   assertEquals(ErrorType.NOTPOSSIBLE, inventory.queryRemoveItem(InventorySlot.AMMO));
 }
示例#13
0
 @Test
 public void isOnlyVisibleToTheOwner() {
   assertTrue(inventory.isVisibleTo(player));
   assertFalse(inventory.isVisibleTo(new TestableCreature(1, "1")));
 }
示例#14
0
 @Test
 public void locationOfNonItemThingIsNull() {
   TestableCreature creature = new TestableCreature(1, "1");
   ItemLocation loc = inventory.getLocationOf(creature);
   assertNull(loc);
 }
示例#15
0
 @Test
 public void contentsSpectatorsOfNonPlayerTypeIsEmpty() {
   Spectators<TestableCreature> s = inventory.getContentsSpectators(TestableCreature.class);
   Iterator<TestableCreature> it = s.iterator();
   assertFalse(it.hasNext());
 }
示例#16
0
 @Test
 public void hasPlayer() {
   assertSame(player, inventory.getPlayer());
 }
示例#17
0
 @Test
 public void hasInternal() {
   assertNotNull(inventory.getInternal());
 }
示例#18
0
 @Test
 public void locationOfUnknownItemIsNull() {
   Item item = getRegularItem();
   ItemLocation loc = inventory.getLocationOf(item);
   assertNull(loc);
 }
示例#19
0
 @Test
 public void queryAddItemRequiresPickupableItem() {
   Item item = createItem(new ItemType()); // Not pickupable
   assertEquals(ErrorType.CANNOTPICKUP, inventory.queryAddItem(InventorySlot.LEFT, item));
 }
示例#20
0
 @Test
 public void executeAddItemAddsItem() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.ARMOR, item);
   assertEquals(item, inventory.getItem(InventorySlot.ARMOR));
 }
示例#21
0
 @Test
 public void queryRemoveItemRequiresKnownItem() {
   Item item = getRegularItem();
   assertEquals(ErrorType.NOTPOSSIBLE, inventory.queryRemoveItem(item));
 }
示例#22
0
 @Test
 public void queryRemoveItemValid() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.ARMOR, item);
   assertEquals(ErrorType.NONE, inventory.queryRemoveItem(item));
 }