mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Added Test for LevelInfo Class (#3930)
This commit is contained in:
		
							parent
							
								
									3f23ea0723
								
							
						
					
					
						commit
						abdd16c063
					
				
					 1 changed files with 82 additions and 0 deletions
				
			
		|  | @ -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) | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Madhur Gupta
						Madhur Gupta