Skip to content

Commit 82afdaf

Browse files
committed
feat(58): Added the tests cases for the 'result()' assertion
1 parent 2cc3dd8 commit 82afdaf

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
package `in`.rcard.assertj.arrowcore
22

3+
import `in`.rcard.assertj.arrowcore.Dummy.aFunctionThatRaisesAnError
4+
import `in`.rcard.assertj.arrowcore.Dummy.aFunctionThatThrowsAnException
5+
import `in`.rcard.assertj.arrowcore.Dummy.aFunctionWithContext
6+
import `in`.rcard.assertj.arrowcore.RaiseAssert.Companion.assertThat
7+
import `in`.rcard.assertj.arrowcore.errors.RaiseShouldSucceedButFailed.Companion.shouldSucceedButFailed
8+
import org.assertj.core.api.Assertions
39
import org.junit.jupiter.api.Test
410

511
internal class RaiseAssert_result_Test {
612
@Test
7-
fun `should return a valid Object Assert if the Raise returns a result`() {
8-
TODO("Not yet implemented")
13+
internal fun `should return a valid Object Assert if the Raise returns a result`() {
14+
assertThat { aFunctionWithContext(42) }.result().isEqualTo(42)
915
}
1016

1117
@Test
12-
fun `should fails if the Raise raised an error`() {
13-
TODO("Not yet implemented")
18+
internal fun `should fails if the Raise raised an error`() {
19+
Assertions
20+
.assertThatThrownBy { assertThat { aFunctionThatRaisesAnError() }.result() }
21+
.isInstanceOf(AssertionError::class.java)
22+
.hasMessage(shouldSucceedButFailed("LOGICAL ERROR").create())
23+
}
24+
25+
@Test
26+
internal fun `should rethrow the inner exception`() {
27+
Assertions
28+
.assertThatThrownBy { assertThat { aFunctionThatThrowsAnException() }.result() }
29+
.isInstanceOf(RuntimeException::class.java)
30+
.hasMessage("AN EXCEPTION")
1431
}
1532
}

0 commit comments

Comments
 (0)