src/test/java/de/uapcore/sudoku/SudokuTest.java

Tue, 28 Jul 2020 14:27:14 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 28 Jul 2020 14:27:14 +0200
changeset 22
06170a0be62a
parent 20
a95423d37588
permissions
-rw-r--r--

bugfix: modified state is reset even when saving fails + more tests

20
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 package de.uapcore.sudoku;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 import org.junit.jupiter.api.AfterEach;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 import org.junit.jupiter.api.BeforeEach;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 import org.junit.jupiter.api.Test;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 import javax.swing.*;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 import static org.junit.jupiter.api.Assertions.assertEquals;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 import static org.junit.jupiter.api.Assertions.assertTrue;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 class SudokuTest {
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 private Sudoku subject;
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 @BeforeEach
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 void init() {
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 subject = new Sudoku();
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 }
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 @AfterEach
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 void destroy() {
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 subject.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 subject.dispose();
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 }
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 @Test
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 void testDefaultCloseOperation() {
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 assertEquals(WindowConstants.EXIT_ON_CLOSE, subject.getDefaultCloseOperation());
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 }
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 @Test
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 void testMinimumSize() {
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 assertEquals(subject.getSize(), subject.getMinimumSize());
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 }
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 @Test
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 void testLocationByPlattform() {
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 assertTrue(subject.isLocationByPlatform());
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 }
a95423d37588 adds more tests
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 }

mercurial