[ADD] Test thematique

Android
Renaud BEURET 1 year ago
parent 528c15e63c
commit 6c835b7195

@ -49,7 +49,6 @@ class KahootViewModel(
// NOTE : tpsReponse en ms
fun ajouterPoints(tpsReponse: Long) {
Log.d("KahootViewModel",tpsReponse.toString())
if (tpsReponse < 0) {
throw IllegalArgumentException("ERREUR: Temps négatif donné à l'ajout de points")
} else if (tpsReponse > uiState.value.dureePartie) {

@ -0,0 +1,49 @@
package fr.iut.sciencequest.dto
import android.os.Looper
import fr.iut.sciencequest.model.dto.ThematiqueDTO
import fr.iut.sciencequest.model.dto.extensions.ToModel
import fr.iut.sciencequest.model.repositories.question.QuestionStubRepository
import fr.iut.sciencequest.stub.StubQuestionWithReponses
import fr.iut.sciencequest.testRules.MainDispatcherRule
import fr.iut.sciencequest.viewModels.KahootViewModel
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
class ThematiqueDTOTest(
val id: Int,
val libelle: String
) {
@Test
fun constructorTest() {
val thematique = ThematiqueDTO(id,libelle)
Assert.assertEquals(id, thematique.id)
Assert.assertEquals(libelle, thematique.libelle)
}
companion object {
@JvmStatic
@Parameterized.Parameters(
name = "Quand le joueur prend {0} ms pour faire son action, il est censé avoir {1} points"
)
fun getTestActionData(): Iterable<Array<Any>> {
return arrayListOf(
arrayOf(1,""),
arrayOf(0,""),
arrayOf(1,"thematique"),
arrayOf(0,"une autre thematique")
)
}
}
}

@ -0,0 +1,37 @@
package fr.iut.sciencequest.model
import fr.iut.sciencequest.model.metier.Thematique
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@RunWith(Parameterized::class)
class ThematiquesTest(
val id: Int,
val libelle: String
) {
@Test
fun constructorTest() {
val thematique = Thematique(id,libelle)
Assert.assertEquals(id, thematique.id)
Assert.assertEquals(libelle, thematique.libelle)
}
companion object {
@JvmStatic
@Parameterized.Parameters(
name = "Quand le joueur prend {0} ms pour faire son action, il est censé avoir {1} points"
)
fun getTestActionData(): Iterable<Array<Any>> {
return arrayListOf(
arrayOf(1,""),
arrayOf(0,""),
arrayOf(1,"thematique"),
arrayOf(0,"une autre thematique")
)
}
}
}
Loading…
Cancel
Save