private void assertOriginalState() { // capture state right after the cast-on row before startNewRow() is // called assertEquals(1, engine.getTotalRowsCompleted()); assertEquals(1, engine.getCurrentRowNumber()); assertEquals(40, engine.getTotalNumberOfStitchesInRow()); assertEquals(0, engine.getStitchesRemainingInRow()); assertEquals(Direction.FORWARDS, engine.getDirection()); assertEquals(KnittingShape.FLAT, engine.getKnittingShape()); }
@Test public void checkStitchCountsAndKnittingShapeRestored() throws Exception { engine.startNewRow(); assertEquals(Direction.BACKWARDS, engine.getDirection()); engine.knit(10); for (int i = 0; i < 10; i++) { engine.knitTwoTogether(); } engine.knit(10); assertEquals(2, engine.getCurrentRowNumber()); assertEquals(30, engine.getTotalNumberOfStitchesInRow()); engine.endRow(); assertEquals(2, engine.getTotalRowsCompleted()); engine.declareRoundKnitting(); assertEquals(KnittingShape.ROUND, engine.getKnittingShape()); engine.startNewRow(); engine.knit(5); }