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
describe("isPersonRetired") { | |
describe("when hasPersonWorked is true") { | |
beforeEachGroup { | |
person.copy(hasPersonWorked = true) | |
} | |
describe("when isActive is true") {...} | |
describe("when isActive is false") {...} |
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
lateinit var person: Person | |
beforeEachGroup { | |
person = Person( | |
name = "name", | |
address = "address", | |
age = 60, | |
isActive = false, | |
// Add new argument | |
hasPersonWorked = false |
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
data class Person( | |
val name: String, | |
val address: String, | |
val age: Int, | |
val isActive: Boolean, | |
val hasPersonWorked: Boolean | |
) { | |
fun isPersonRetired() = | |
hasPersonWorked && (!isActive || age > 60) | |
} |
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
object PersonSpec : Spek({ | |
lateinit var person: Person | |
beforeEachGroup { | |
person = Person( | |
name = "name", | |
address = "address", | |
age = 60, | |
isActive = false |
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
describe("when isActive is false") { | |
beforeEachGroup { | |
person = person.copy(isActive = false) | |
} | |
... | |
describe("when getAge is less than RETIREMENT_AGE") { | |
beforeEachGroup { | |
person = person.copy(age = 55) | |
} | |
it("should return false") { |
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
describe("isPersonRetired") { | |
describe("when isActive is true") { | |
beforeEachGroup { | |
person = person.copy(isActive = true) | |
} | |
describe("when getAge is greater than RETIREMENT_AGE") { | |
beforeEachGroup { person = person.copy(age = 65) } | |
} | |
describe("when getAge is less than RETIREMENT_AGE") { | |
beforeEachGroup { person = person.copy(age = 55) } |
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
object PersonSpec : Spek({ | |
}) |
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
lateinit var person: Person | |
beforeEachGroup { | |
person = Person( | |
name = "name", | |
address = "address", | |
age = 60, | |
isActive = false | |
) | |
} |
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
private const val RETIREMENT_AGE = 60 | |
data class Person( | |
val name: String, | |
val address: String, | |
val age: Int, | |
val isActive: Boolean | |
) { | |
fun isPersonRetired() = | |
!isActive || age > RETIREMENT_AGE |
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
@Entity | |
data class Item { | |
@PrimaryKey | |
@Embedded ItemId id, | |
... | |
} | |
data class ItemId { | |
long categoryId, | |
int itemId |
NewerOlder