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 org.junit.Assert.assertTrue | |
fun assertTrueWithMessage(input: Any, expectedOutput: Any, actualOutput: Any) { | |
assertTrue( | |
createMessage(input, expectedOutput, actualOutput), | |
actualOutput == expectedOutput) | |
} | |
fun createMessage(input: Any, expectedOutput: Any, actualOutput: Any): String { | |
return "input was\n $input\n " + |
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
package com.publicmethod.domain.pipelines | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.* | |
import kotlinx.coroutines.selects.SelectBuilder | |
import kotlinx.coroutines.selects.select | |
interface Pipeline<I, O> : SendChannel<I>, ReceiveChannel<O> | |
open class PipelineBuilder<I, O>( |
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
@Test | |
fun given_1_when_send_then_string_of_1() { | |
// Arrange | |
val input: Int = 1 | |
val expected: String = "1" | |
lateinit var actual: String | |
// Act | |
CoroutineTestingScope.launch { | |
intToStringPipeline.send(input) |
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
interface Pipeline<I, O> : SendChannel<I>, ReceiveChannel<O> |
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 lateinit var intToStringPipeline: Pipeline<Int, String> | |
@Before | |
fun setUp() { | |
intToStringPipeline = CoroutineTestingScope.pipeline() { | |
for (number in channel) { | |
send { number.toString() } | |
} | |
} | |
} |
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 <I, O> CoroutineScope.pipeline(): Pipeline<I, O> { | |
} |
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 <I, O> CoroutineScope.pipeline(init: suspend PipelineBuilder<I, O>.() -> Unit): Pipeline<I, O> { |
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 PipelineBuilder() |
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 <I, O> CoroutineScope.pipeline(init: PipelineBuilder.() -> Unit): Pipeline<I, O> { | |
} |
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 PipelineBuilder<I>( | |
actorScope: ActorScope<I> | |
) : ActorScope<I> by actorScope { | |
} |
OlderNewer