-
-
Save kuamanet/3b4dd87088150df675db48f65327348e to your computer and use it in GitHub Desktop.
QuickBird Developer Team Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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