value [m] | displayed string |
---|---|
753 | 753 m |
1337 | 1.34 km |
15888 | 15.9 km |
31270 | 31 km |
51000 | >50 km |
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
val testCases = mapOf( | |
61888.123 to ">50 km", | |
38777.23 to "38.8 km", | |
16984.44 to "17.0 km", | |
987.98 to "988 m" | |
) |
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
@RunWith(Parameterized::class) | |
class FibonacciTest(private val fInput: Int, private val fExpected: Int) { | |
@Test | |
fun test() { | |
assertEquals(fExpected, Fibonacci.compute(fInput)) | |
} | |
companion object { | |
@JvmStatic |
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
class DistanceConverterSpecificiation : Spek({ | |
describe("distance converter") { | |
val testCases = mapOf( | |
61888.123 to ">50 km", | |
38777.23 to "38.8 km", | |
16984.44 to "17.0 km", | |
987.98 to "988 m" | |
) | |
val converter = DistanceConverter() | |
testCases.forEach { value, expectedValue -> |
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
testCases.forEach { value, expectedValue -> | |
on("$value"){ | |
it("should print $expectedValue"){} | |
} | |
} |
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
val testCases = mapOf( | |
61888.123 to ">50 km", | |
38777.23 to "38.8 km", | |
16984.44 to "17.0 km", | |
987.98 to "988 m" | |
) |
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
class DistanceConverterSpecificiation : Spek({ | |
describe("distance converter") { | |
val distanceConverter: DistanceConverter by memoized { | |
DistanceConverter() | |
} | |
on("distance 61888.123m") { | |
val testDistance = 61888.123 | |
it("should return >50km") { | |
val convert = distanceConverter.convert(testDistance) | |
assertTrue(convert.contentEquals(">50km")) |
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
@Parameters | |
public static Collection<Object[]> data() { | |
return Arrays.asList(new Object[][] { | |
{ 0, 0 }, { 1, 1 }, { 2, 1 } | |
}); | |
} |
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
given("no people in repository"){ | |
val view: PeopleListContract.View = mock() | |
val repository : Repository<Person> = mock { | |
on { getAll() } doReturn Single.error(Error("no data")) | |
} | |
val presenter = PeopleListPresenter(repository) | |
on("presenter attach"){ | |
presenter.attach(view) | |
presenterAttachStandardFlow(view, presenter){ | |
it("should not add anything to view"){ |
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
fun SpecBody.detachPresenterAction(presenter: PeopleListPresenter) { | |
on("presenter detach") { | |
presenter.detach() | |
it("should detach view") { | |
Assert.assertNull(presenter.view) | |
} | |
} | |
} |