6

I'm trying to use the WCF test client to debug a web method and the method expects 2 byte arrays as part of its input.

For now, I've just been using the debugger and placing breakpoints right before the passed values get used, and setting them with the visual studio watch window.

Is there an easy way to set the values for each byte of a byte array using WCF test client?

I know you can specify the length of the array by typing "length=100" or similar, but that only sets the size of the array. You then have to click the drop down and enter the value for each and every byte one by one.

Does anyone have experience entering values for arrays when using the WCF test client?

4

2 回答 2

0

我所做的是创建一个接受数组和新值的静态方法(有时我传递一个逗号分隔的字符串并将其拆分,有时我传递一个“参数”arg 等)。

有了这个,您可以在调试器监视或即时窗口上调用该方法。例如,您可以在需要预设值的任何时候调用“SetArrayOne()”,或者您可以调用“SetArray(...)”并传递所需的参数:

byte[] myClassLevelArray1 = new byte[10];
byte[] myClassLevelArray2 = new byte[10];

public void SetArrayOne()
{
    SetArray(myClassLevelArray1, 1, 2, 3, 4, 5);
}

public void SetArrayTwo()
{
    SetArray(myClassLevelArray2, 1, 2, 3, 4, 5, 8, 9, 10, 11, 15, 20, 5, 98, 5, 4);
}

public static void SetArray(byte[] myArray, params byte[] newValues)
{
    Array.Copy(newValues, myArray, Math.Min(newValues.Length, myArray.Length));
}
于 2014-05-06T16:42:15.250 回答
0

我最终创建了一个不接收参数的新方法,它只是调用了我想要测试的方法,在那里设置了数组值。

于 2014-12-16T18:43:10.393 回答