Added Test for LevelInfo Class (#3930)

This commit is contained in:
Madhur Gupta 2020-09-14 07:01:25 +05:30 committed by GitHub
parent 3f23ea0723
commit abdd16c063
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,82 @@
package fr.free.nrw.commons.profile.achievements
import fr.free.nrw.commons.R
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.mockito.Mock
import org.mockito.MockitoAnnotations
/**
* Test for the Level Controller Class for Achievements
*/
class LevelControllerTest {
@Mock
private lateinit var levelController: LevelController
private val IMAGES_UPLOADED_SAMPLE_VALUE = 0
private val UNIQUE_IMAGES_USED_SAMPLE_VALUE = 0
private val NON_REVERT_RATE_SAMPLE_VALUE = 0
private lateinit var levelInfo: LevelController.LevelInfo
/**
* Setups the mock objects for the tests
*/
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
levelController = LevelController()
levelInfo = LevelController.LevelInfo.from(
IMAGES_UPLOADED_SAMPLE_VALUE,
UNIQUE_IMAGES_USED_SAMPLE_VALUE,
NON_REVERT_RATE_SAMPLE_VALUE
)
}
/**
* Tests if Level number for sample values is equal to actual value or not
*/
@Test
fun testLevelNumber() {
assertEquals(levelInfo.levelNumber, 1)
}
/**
* Tests if Level Style for Level with sample values is equal to actual value or not
*/
@Test
fun testLevelStyle() {
assertEquals(levelInfo.levelStyle, R.style.LevelOne)
}
/**
* Tests if Maximum Unique Images for Level with sample values is equal to actual value
* or not
*/
@Test
fun testMaxUniqueImages() {
assertEquals(levelInfo.maxUniqueImages, 5)
}
/**
* Tests if Maximum Upload Count for Level with sample values is equal to actual value
* or not
*/
@Test
fun testMaxUploadCount() {
assertEquals(levelInfo.maxUploadCount, 20)
}
/**
* Tests if the Minimum Non Revert Percentage for Level with sample values is equal to
* actual value or not
*/
@Test
fun testMinNonRevertPercentage() {
assertEquals(levelInfo.minNonRevertPercentage, 85)
}
}