@Test public void twentyFor4x5RectangleFromSquare() throws Exception { final Rectangle rectangle = new Rectangle(); rectangle.setWidth(5); rectangle.setHeight(4); final Square square = new Square(); square.setSideLength(3); List<Shape> shapes = new ArrayList<Shape>() { { add(rectangle); add(square); } }; List<Integer> areas = new ArrayList<Integer>(); for (Shape shape : shapes) { areas.add(shape.area()); } assertEquals(20, areas.get(0).intValue()); assertEquals(9, areas.get(1).intValue()); }
@Test public void nineFor3x3Square() throws Exception { Square square = new Square(); square.setSideLength(3); assertEquals(9, square.area()); }