コード例 #1
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());
 }
コード例 #2
0
 @Test
 public void singleObject() {
   Player player = context.mock(Player.class);
   Spectators<Player> s = new SimpleSpectators<Player>(player);
   Iterator<Player> it = s.iterator();
   assertTrue(it.hasNext());
   assertSame(player, it.next());
   assertFalse(it.hasNext());
 }
コード例 #3
0
 @Test
 public void filtersInvalidSpectators() {
   Player player = context.mock(Player.class);
   Creature c1 = context.mock(Creature.class);
   Spectators<Player> s = new SimpleSpectators<Player>(Player.class, Arrays.asList(c1, player));
   Iterator<Player> it = s.iterator();
   assertTrue(it.hasNext());
   assertSame(player, it.next());
   assertFalse(it.hasNext());
 }
コード例 #4
0
 @Test
 public void copiesInputCollection() {
   Player player = context.mock(Player.class);
   Creature c1 = context.mock(Creature.class);
   Spectators<Creature> s = new SimpleSpectators<Creature>(Arrays.asList(c1, player));
   Iterator<Creature> it = s.iterator();
   assertTrue(it.hasNext());
   assertSame(c1, it.next());
   assertTrue(it.hasNext());
   assertSame(player, it.next());
   assertFalse(it.hasNext());
 }
コード例 #5
0
 @Test
 public void isEmptyByDefault() {
   Spectators<Player> s = new SimpleSpectators<Player>();
   assertFalse(s.iterator().hasNext());
 }
コード例 #6
0
 @Test
 public void providesEmptyInstance() {
   Spectators<Player> s = SimpleSpectators.getEmpty(Player.class);
   assertFalse(s.iterator().hasNext());
   assertNull(s.iterator().next());
 }
コード例 #7
0
 @Test
 public void contentsSpectatorsOfNonPlayerTypeIsEmpty() {
   Spectators<TestableCreature> s = inventory.getContentsSpectators(TestableCreature.class);
   Iterator<TestableCreature> it = s.iterator();
   assertFalse(it.hasNext());
 }