@Test public void testEmptyVectorGraphics2DStartsWithCreateCommand() { VectorGraphics2D g = new VectorGraphics2D(); Iterable<Command<?>> commands = g.getCommands(); Iterator<Command<?>> commandIterator = commands.iterator(); assertTrue(commandIterator.hasNext()); Command<?> firstCommand = commandIterator.next(); assertTrue(firstCommand instanceof CreateCommand); assertEquals(g, ((CreateCommand) firstCommand).getValue()); }
@Test public void testCreateEmitsCreateCommand() { VectorGraphics2D g = new VectorGraphics2D(); Iterable<Command<?>> gCommands = g.getCommands(); Iterator<Command<?>> gCommandIterator = gCommands.iterator(); CreateCommand gCreateCommand = (CreateCommand) gCommandIterator.next(); VectorGraphics2D g2 = (VectorGraphics2D) g.create(); CreateCommand g2CreateCommand = null; for (Command<?> g2Command : g2.getCommands()) { if (g2Command instanceof CreateCommand) { g2CreateCommand = (CreateCommand) g2Command; } } assertNotEquals(gCreateCommand, g2CreateCommand); assertEquals(g2, g2CreateCommand.getValue()); }