5

我的旧版(不可测试)dll 中有一个带有 ref 参数的静态方法。我正在尝试为调用此方法的类编写单元测试。

public static class Branding
{
    ...
    ...

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

    ...
    ...
}

我需要帮助为此调用编写 shim 语句

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

谢谢!

4

1 回答 1

19
using (ShimsContext.Create())
{
    ShimBranding.GetBrandingInt32Int32StringStringRef =
        (int providerId, int employerId, string brandingElement, ref string brandingValue) =>
        {
            brandingValue = "Blah";
            return true;
        };
}
于 2012-10-13T00:12:06.577 回答