2

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?

adam0101
  • 29,096
  • 21
  • 96
  • 174
  • Ever got this working? – NotFound Nov 09 '20 at 14:49
  • @404, I've moved on to a different job so I haven't needed to, but I do see that the author of the project is hoping to revive the project, so there maybe there's hope: https://github.com/tonerdo/pose/issues/63 – adam0101 Nov 16 '20 at 18:49

0 Answers0