Question

I have a static method with ref parameters in my legacy (untestable) dll. I am trying to write unit tests for a class that calls into this method.

public static class Branding
{
    ...
    ...

    static public bool GetBranding(Int32 providerId,
        Int32 employerId,
        string brandingElement,
        ref string brandingValue)

    ...
    ...
}

I need help writing a shim statement for this call

ShimBranding.GetBrandingInt32Int32StringStringRef = 
    ( providerId, employerId, element, { ====> WHAT GOES HERE <===== } )
    => 
    true;

Thanks!

Was it helpful?

Solution

using (ShimsContext.Create())
{
    ShimBranding.GetBrandingInt32Int32StringStringRef =
        (int providerId, int employerId, string brandingElement, ref string brandingValue) =>
        {
            brandingValue = "Blah";
            return true;
        };
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top