Format GeneratorSdkSourceTest (#324)

This commit is contained in:
David Perez 2023-12-05 10:46:15 -06:00 committed by Álison Fernandes
parent c3e0843505
commit fad80fbd69

View file

@ -14,57 +14,57 @@ class GeneratorSdkSourceTest {
private val clientGenerators = mockk<ClientGenerators>() private val clientGenerators = mockk<ClientGenerators>()
private val generatorSdkSource: GeneratorSdkSource = GeneratorSdkSourceImpl(clientGenerators) private val generatorSdkSource: GeneratorSdkSource = GeneratorSdkSourceImpl(clientGenerators)
@Suppress("MaxLineLength")
@Test @Test
fun `generatePassword should call SDK and return a Result with the generated password`() = runBlocking { fun `generatePassword should call SDK and return a Result with the generated password`() =
val request = PasswordGeneratorRequest( runBlocking {
lowercase = true, val request = PasswordGeneratorRequest(
uppercase = true, lowercase = true,
numbers = true, uppercase = true,
special = true, numbers = true,
length = 12.toUByte(), special = true,
avoidAmbiguous = false, length = 12U,
minLowercase = 1U, avoidAmbiguous = false,
minUppercase = 1U, minLowercase = 1U,
minNumber = 1U, minUppercase = 1U,
minSpecial = 1U, minNumber = 1U,
) minSpecial = 1U,
val expectedResult = "GeneratedPassword123!" )
val expectedResult = "GeneratedPassword123!"
coEvery { coEvery {
clientGenerators.password(request) clientGenerators.password(request)
} returns expectedResult } returns expectedResult
val result = generatorSdkSource.generatePassword(request) val result = generatorSdkSource.generatePassword(request)
assertEquals(Result.success(expectedResult), result) assertEquals(Result.success(expectedResult), result)
coVerify { coVerify {
clientGenerators.password(request) clientGenerators.password(request)
}
} }
}
@Suppress("MaxLineLength")
@Test @Test
fun `generatePassphrase should call SDK and return a Result with the generated passphrase`() = runBlocking { fun `generatePassphrase should call SDK and return a Result with the generated passphrase`() =
val request = PassphraseGeneratorRequest( runBlocking {
numWords = 4.toUByte(), val request = PassphraseGeneratorRequest(
wordSeparator = "-", numWords = 4U,
capitalize = true, wordSeparator = "-",
includeNumber = true, capitalize = true,
) includeNumber = true,
val expectedResult = "Generated-Passphrase123" )
val expectedResult = "Generated-Passphrase123"
coEvery { coEvery {
clientGenerators.passphrase(request) clientGenerators.passphrase(request)
} returns expectedResult } returns expectedResult
val result = generatorSdkSource.generatePassphrase(request) val result = generatorSdkSource.generatePassphrase(request)
assertEquals(Result.success(expectedResult), result) assertEquals(Result.success(expectedResult), result)
coVerify { coVerify {
clientGenerators.passphrase(request) clientGenerators.passphrase(request)
}
} }
}
} }