Scenario: I have a web service client class which is consuming the reference.cs generated by VSNet2003 from the wsdl url.
The web service provides a class type which has a public field of type string - this class type is used as an argument for one of the method calls.
I construct a new instance of this type during my wrapper method, set the string field value and then call the webmethod wrapper in the reference.cs - how can I verify that the string field is set?
e.g.
public string[] GetSupportedIndexes(string currency)
{
try
{
getSupportedIndexes getSupportedIndexes = new getSupportedIndexes();
getSupportedIndexes.String_1 = currency;
return this.tradeServicesClient.getSupportedIndexes(getSupportedIndexes);
}
catch (Exception e)
{
throw new TradeServicesProviderException("WebMethod getSupportedIndexes threw an exception", e);
}
}
I can ExpectConstructor() but can't think of how to verify the String_1 field gets set - ExpectSet fails since it expects a proeprty setter and String_1 is a field....
[Test]
public void GetSupportedIndexesTest()
{
this.mockGetSupportedIndexes.ExpectConstructor();
this.mockSWM_TradeService.ExpectAndReturn("getSupportedIndexes", this.expectedIndices).Args(Check.IsMock(this.mockGetSupportedIndexes));
string[] actual = this.jBossTradeServicesProvider.GetSupportedIndexes(this.expectedCurrency);
Assert.AreSame(this.expectedIndices, actual);
}
I *could* ask the web service developers to make 2 methods on the class for setting and getting the field value but that seems a bit lame....
I *could* not mock the getSupportedIndexes class and make it a private field, get and set values to check via reflection but again it seems a bit over the top to test that a single field is getting set....
I tried creating a test webservice with a public class containing a property encapsulating string1 private field but the wsdl tool converted it to a public field....
Any ideas? :?