1
+ package fr.free.nrw.commons.profile.achievements
2
+
3
+ import fr.free.nrw.commons.R
4
+ import org.junit.Assert.assertEquals
5
+ import org.junit.Before
6
+ import org.junit.Test
7
+ import org.mockito.Mock
8
+ import org.mockito.MockitoAnnotations
9
+
10
+ /* *
11
+ * Test for the Level Controller Class for Achievements
12
+ */
13
+ class LevelControllerTest {
14
+
15
+ @Mock
16
+ private lateinit var levelController: LevelController
17
+
18
+ private val IMAGES_UPLOADED_SAMPLE_VALUE = 0
19
+
20
+ private val UNIQUE_IMAGES_USED_SAMPLE_VALUE = 0
21
+
22
+ private val NON_REVERT_RATE_SAMPLE_VALUE = 0
23
+
24
+ private lateinit var levelInfo: LevelController .LevelInfo
25
+
26
+ /* *
27
+ * Setups the mock objects for the tests
28
+ */
29
+ @Before
30
+ fun setUp () {
31
+ MockitoAnnotations .initMocks(this )
32
+ levelController = LevelController ()
33
+ levelInfo = LevelController .LevelInfo .from(
34
+ IMAGES_UPLOADED_SAMPLE_VALUE ,
35
+ UNIQUE_IMAGES_USED_SAMPLE_VALUE ,
36
+ NON_REVERT_RATE_SAMPLE_VALUE
37
+ )
38
+ }
39
+
40
+ /* *
41
+ * Tests if Level number for sample values is equal to actual value or not
42
+ */
43
+ @Test
44
+ fun testLevelNumber () {
45
+ assertEquals(levelInfo.levelNumber, 1 )
46
+ }
47
+
48
+ /* *
49
+ * Tests if Level Style for Level with sample values is equal to actual value or not
50
+ */
51
+ @Test
52
+ fun testLevelStyle () {
53
+ assertEquals(levelInfo.levelStyle, R .style.LevelOne )
54
+ }
55
+
56
+ /* *
57
+ * Tests if Maximum Unique Images for Level with sample values is equal to actual value
58
+ * or not
59
+ */
60
+ @Test
61
+ fun testMaxUniqueImages () {
62
+ assertEquals(levelInfo.maxUniqueImages, 5 )
63
+ }
64
+
65
+ /* *
66
+ * Tests if Maximum Upload Count for Level with sample values is equal to actual value
67
+ * or not
68
+ */
69
+ @Test
70
+ fun testMaxUploadCount () {
71
+ assertEquals(levelInfo.maxUploadCount, 20 )
72
+ }
73
+
74
+ /* *
75
+ * Tests if the Minimum Non Revert Percentage for Level with sample values is equal to
76
+ * actual value or not
77
+ */
78
+ @Test
79
+ fun testMinNonRevertPercentage () {
80
+ assertEquals(levelInfo.minNonRevertPercentage, 85 )
81
+ }
82
+ }
0 commit comments