Entering values ​​for a byte array in a WCF test client

I am trying to use the WCF test client to debug a web method, and the method expects 2 byte arrays to be part of its input.

Currently, I just used a debugger and placed breakpoints just before using the transferred values ​​and set them in the visual studio view window.

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

I know that you can specify the length of the array by typing "length = 100" or similar, but this only sets the size of the array. Then you need to click the dropdown menu and enter a value for each byte one at a time.

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

+6
source share
2 answers

I created a static method that takes an array and a new value (sometimes I pass a string separated by commas and separate it, sometimes I pass the argument "params", etc.).

Using this method, you can call this method in the debug window or in the nearest window. For example, you can call "SetArrayOne ()" anytime you need to pre-set values, or you can call "SetArray (...)" and pass the arguments you need:

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)); } 
0
source

I ended up creating a new method that did not receive the parameters that were just called the method that I wanted to test by setting the value of the array there.

0
source

Source: https://habr.com/ru/post/944929/


All Articles