Skip to content

Instantly share code, notes, and snippets.

@kuamanet
Created August 1, 2020 06:27
Show Gist options
  • Save kuamanet/3b4dd87088150df675db48f65327348e to your computer and use it in GitHub Desktop.
Save kuamanet/3b4dd87088150df675db48f65327348e to your computer and use it in GitHub Desktop.
QuickBird Developer Team Test
import io.mockk.every
import io.mockk.mockk
import org.junit.Test
/**
* Represents a QuickBird team member
*/
class TeamMember(val isPassionate: Boolean, val isFriendly: Boolean, val isConstantlyImproving: Boolean)
/**
* Expresses how a team member is awesome
*/
val TeamMember.isAwesome: Boolean
get() = isPassionate && isFriendly && isConstantlyImproving
/**
* Expresses when a list of team members is awesome
*/
val List<TeamMember>.areAwesome: Boolean
get() = all { it.isAwesome }
interface TeamMemberRepository {
fun fetchTeamMembers(): List<TeamMember>
}
class TeamMemberTest {
@Test
fun `test team is awesome`() {
val repoMock = mockk<TeamMemberRepository>(relaxed = true)
every { repoMock.fetchTeamMembers() } returns (0..10).map { TeamMember(
isPassionate = true,
isConstantlyImproving = true,
isFriendly = true
) }
val teamMembers = repoMock.fetchTeamMembers()
assert(teamMembers.areAwesome)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment