PraktikumHolonsTestAutoSaveController.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package tests;
  2. import org.junit.Before;
  3. import org.junit.Test;
  4. import static org.junit.Assert.*;
  5. import ui.controller.AutoSaveController;
  6. import ui.model.Model;
  7. /**
  8. * Tests for the AutoSaveController.
  9. *
  10. * @author Gruppe14
  11. */
  12. public class PraktikumHolonsTestAutoSaveController {
  13. protected Model model;
  14. protected AutoSaveController controller;
  15. /**
  16. * Setup for the test.
  17. */
  18. @Before
  19. public void setUp() {
  20. model = new Model();
  21. controller = new AutoSaveController(model);
  22. }
  23. /**
  24. * Tests for the AutoSavController.
  25. * The AutoSaveController only contains indices for the actual save file.
  26. */
  27. @Test
  28. public void testAutoSave() {
  29. int temp = controller.getAutoSaveNr();
  30. assertTrue("AutoSave Number not forrect", temp == -1);
  31. controller.increaseAutoSaveNr();
  32. assertTrue("AutoSave Number not forrect", controller.getAutoSaveNr() == 0);
  33. for (int i = 0; i < 20; i++) {
  34. controller.increaseAutoSaveNr();
  35. }
  36. assertTrue("AutoSave Number not correct", controller.getAutoSaveNr() == 20);
  37. assertTrue("Is Allowed not set", controller.allowed());
  38. for (int i = 0; i < 20; i++) {
  39. controller.decreaseAutoSaveNr();;
  40. }
  41. assertTrue("AutoSave Number not correct", controller.getAutoSaveNr() == 0);
  42. }
  43. }