@Test
fun gameViewModel_Initialization_FirstWordLoaded() {
val currentGameUiState = viewModel.uiState.value
val unScrambledWord = getUnscrambledWord(currentGameUiState.currentScrambledWord)
}
To verify the state is correct, add the assertTrue() functions to assert that the currentWordCount property is set to 1, and the score property is set to 0.
Add assertFalse() functions to verify that the isGuessedWordWrong property is false and that the isGameOver property is set to false.
@Test
fun gameViewModel_Initialization_FirstWordLoaded() {
val gameUiState = viewModel.uiState.value
val unScrambledWord = getUnscrambledWord(gameUiState.currentScrambledWord)
// Assert that current word is scrambled.
assertNotEquals(unScrambledWord, gameUiState.currentScrambledWord)
// Assert that current word count is set to 1.
assertTrue(gameUiState.currentWordCount == 1)
// Assert that initially the score is 0.
assertTrue(gameUiState.score == 0)
// Assert that the wrong word guessed is false.
assertFalse(gameUiState.isGuessedWordWrong)
// Assert that game is not over.
assertFalse(gameUiState.isGameOver)
}
This part, I see the variable name suddenly changed from currentGameUiState to gameUiState.
To verify the state is correct, add the assertTrue() functions to assert that the currentWordCount property is set to 1, and the score property is set to 0. Add assertFalse() functions to verify that the isGuessedWordWrong property is false and that the isGameOver property is set to false.
This part, I see the variable name suddenly changed from
currentGameUiState
togameUiState
.