I'm trying to use https://github.com/tonerdo/pose. I have a method in another assembly that looks like this (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)
...
I'm trying to figure out how to shim this. This give me the error 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; });
This give me 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; });
And these variations give me 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; });
What is the proper syntax?