我正在尝试使用https://github.com/tonerdo/pose。我在另一个程序集中有一个方法,看起来像这样(VB.NET):
Public Class Item Parent
Public Function GetItems(
ByVal Optional a As Integer = 0,
ByVal Optional b As Integer = 0,
ByVal Optional c As Integer = 0,
ByVal Optional d As Integer = 0) As List(Of Item)
...
我试图弄清楚如何填充这个。这给了我错误An expression tree may not contain a call or invocation that uses optional arguments
。
var mockItems = new List<Item>();
Shim.Replace(() => Is.A<ItemParent>().GetItems())
.With(delegate (ItemParent@this) { return mockItems; });
这给我Pose.Exceptions.InvalidShimSignatureException: Mismatched instance types
var mockItems = new List<Item>();
Shim.Replace(() => Is.A<ItemParent>().GetItems(Is.A<int>(), Is.A<int>(), Is.A<int>(), Is.A<int>()))
.With(delegate () { return mockItems; });
这些变化给了我Pose.Exceptions.InvalidShimSignatureException: Parameters count do not match
var mockItems = new List<Item>();
Shim.Replace(() => Is.A<ItemParent>().GetItems(Is.A<int>(), Is.A<int>(), Is.A<int>(), Is.A<int>()))
.With(delegate (ItemParent@this) { return mockItems; });
var mockItems = new List<Item>();
Shim.Replace(() => Is.A<ItemParent>().GetItems(Is.A<int>(), Is.A<int>(), Is.A<int>(), Is.A<int>()))
.With(delegate (ItemParent@this, int a, int b, int c, int d) { return mockItems; });
什么是正确的语法?