@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()); }
@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()); }
@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()); }
@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()); }
@Test public void isEmptyByDefault() { Spectators<Player> s = new SimpleSpectators<Player>(); assertFalse(s.iterator().hasNext()); }
@Test public void providesEmptyInstance() { Spectators<Player> s = SimpleSpectators.getEmpty(Player.class); assertFalse(s.iterator().hasNext()); assertNull(s.iterator().next()); }
@Test public void contentsSpectatorsOfNonPlayerTypeIsEmpty() { Spectators<TestableCreature> s = inventory.getContentsSpectators(TestableCreature.class); Iterator<TestableCreature> it = s.iterator(); assertFalse(it.hasNext()); }