pose icon indicating copy to clipboard operation
pose copied to clipboard

Question - correct syntaxes

Open alexzaytsev-newsroomly opened this issue 7 years ago • 1 comments

I have 2 use cases that are not immediately clear from the description:

  1. Replacing multiple methods (both static and instance). Do i keep creating Shims for each of the methods, and pass a bunch of them to pose context?

  2. Replacing a method with params argument.

alexzaytsev-newsroomly avatar Oct 16 '17 05:10 alexzaytsev-newsroomly

  1. You'll have to create shims for each static/instance method (and each overload as well) and pass the bunch to PoseContext.

  2. You can simply pass an array in place of the params arguments

E.g.

class Program
{
    public void TakesParams(params string[] them)
    {
        // Do Stuff
    }
}

Shim shim = Shim.Replace(() => Is.A<Program>().TakesParams(Is.A<string[]>())).With((Program @this, string[] them) => Console.WriteLine(them.Length));

tonerdo avatar Oct 18 '17 09:10 tonerdo