Skip to content

Instantly share code, notes, and snippets.

View rozkminiacz's full-sized avatar

Jarosław Michalik rozkminiacz

View GitHub Profile
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"
)
@RunWith(Parameterized::class)
class FibonacciTest(private val fInput: Int, private val fExpected: Int) {
@Test
fun test() {
assertEquals(fExpected, Fibonacci.compute(fInput))
}
companion object {
@JvmStatic
value [m] displayed string
753 753 m
1337 1.34 km
15888 15.9 km
31270 31 km
51000 >50 km
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 ->
testCases.forEach { value, expectedValue ->
on("$value"){
it("should print $expectedValue"){}
}
}
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"
)
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"))
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ 0, 0 }, { 1, 1 }, { 2, 1 }
});
}
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"){
fun SpecBody.detachPresenterAction(presenter: PeopleListPresenter) {
on("presenter detach") {
presenter.detach()
it("should detach view") {
Assert.assertNull(presenter.view)
}
}
}