scalamock 是否支持模拟具有隐式和重复参数的咖喱方法?
Does scalamock support mocking curried mehtod that has implicit and repeated parameters?
我需要使用 scalamock 模拟以下方法,但我没能做到。它是柯里化的,同时具有隐式和重复参数。
scalamock 库是否支持模拟这种组合?
def apply(key: String, args: Any*)(implicit lang: Lang): String
这个怎么样?
"complicated paramter lists" should "be mockable" in {
trait Foo {
def apply(key: String, args: Any*)(implicit lang: String): String
}
val m = mock[Foo]
(m.apply(_: String, _: Seq[Any])(_: String)) expects(*, *, *) returning "Foo" once()
implicit val s = "foo"
m.apply("bar", 5, true, 42.0) should be ("Foo")
}
我需要使用 scalamock 模拟以下方法,但我没能做到。它是柯里化的,同时具有隐式和重复参数。 scalamock 库是否支持模拟这种组合?
def apply(key: String, args: Any*)(implicit lang: Lang): String
这个怎么样?
"complicated paramter lists" should "be mockable" in {
trait Foo {
def apply(key: String, args: Any*)(implicit lang: String): String
}
val m = mock[Foo]
(m.apply(_: String, _: Seq[Any])(_: String)) expects(*, *, *) returning "Foo" once()
implicit val s = "foo"
m.apply("bar", 5, true, 42.0) should be ("Foo")
}