-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(analysis): move mockStartSession to own class #3483
- Loading branch information
1 parent
dca5d4d
commit 5284289
Showing
6 changed files
with
43 additions
and
82 deletions.
There are no files selected for viewing
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
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
25 changes: 25 additions & 0 deletions
25
...eParser/src/test/kotlin/de/maibornwolff/codecharta/tools/interactiveparser/SessionMock.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package de.maibornwolff.codecharta.tools.interactiveparser | ||
|
||
import com.varabyte.kotter.runtime.Session | ||
import com.varabyte.kotterx.test.foundation.testSession | ||
import io.mockk.every | ||
import io.mockk.mockkStatic | ||
|
||
class SessionMock { | ||
companion object { | ||
fun mockStartSession() { | ||
mockkStatic("de.maibornwolff.codecharta.tools.interactiveparser.ParserDialogInterfaceKt") | ||
every { startSession(any<Session.() -> Any>()) } answers { | ||
startTestSession { firstArg<Session.() -> Any>()(this) } | ||
} | ||
} | ||
|
||
private fun <T> startTestSession(block: Session.() -> T): T { | ||
var returnValue: T? = null | ||
testSession { | ||
returnValue = block() | ||
} | ||
return returnValue ?: throw IllegalStateException("Session did not return a value.") | ||
} | ||
} | ||
} |
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
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
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