*/
public class SkipPageTest {
@Test
public void skipPage() throws Exception {
Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\skippagefiles\\skippage.xml")));
Question p0 = model.getQuestionByID("page0");
Question p1 = model.getQuestionByID("page1");
Question p2 = model.getQuestionByID("page2");
assertEquals(0, model.getCurrentPageNumber());
assertTrue(model.isNextPageAvailable());
assertFalse(model.isPreviousPageAvailable());
assertFalse(model.isLastPageAndComplete());
p1.setAnswer("yes"); //skip page 1
p2.setAnswer("yes"); //skip page 2
assertFalse(model.isNextPageAvailable());
assertFalse(model.isPreviousPageAvailable());
assertTrue(model.isLastPageAndComplete());
p2.setAnswer("no"); //make page 2 visitable
assertTrue(model.isNextPageAvailable());
assertFalse(model.isPreviousPageAvailable());
assertFalse(model.isLastPageAndComplete());
model.goToNextPage();
assertEquals(2, model.getCurrentPageNumber());
assertFalse(model.isNextPageAvailable());
assertTrue(model.isPreviousPageAvailable());
assertTrue(model.isLastPageAndComplete());
p1.setAnswer("no"); //make page 1 visitable
assertFalse(model.isNextPageAvailable());
assertTrue(model.isPreviousPageAvailable());
assertTrue(model.isLastPageAndComplete());
model.goToPreviousPage();
assertEquals(1, model.getCurrentPageNumber());
assertTrue(model.isNextPageAvailable());
assertTrue(model.isPreviousPageAvailable());
assertFalse(model.isLastPageAndComplete());
p0.setAnswer("yes"); //skip page 0
assertTrue(model.isNextPageAvailable());
assertFalse(model.isPreviousPageAvailable());
assertFalse(model.isLastPageAndComplete());
}