chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
IList<string> attrNames = new List<string>();
attrNames.Add("foo");

using (RecordExpectations recorder = new RecordExpectations())
{
    obj.RemoveAttributes(attrNames);
    recorder.CheckArguments(attrNames);
}

a little later in the unit test we call a method that then calls obj.RemoveAttributes (the method under test). When that happens obj.RemoveAttributes gets called with a string[] (which implements IList<string> via the framework).
obj.RemoveAttributes(new string[] { "foo" });

The failure is:
TypeMock Verification: Call to MyObject.RemoveAttributes() Parameter: 1 array index [0]
expected: [System.Collections.Generic.List`1[System.String]]
but was: <"foo">


I don't believe that this should happen. At a minimum this is unexpected. Here's my reasoning. The actual call to obj.RemoveAttributes(IList<string> attrNames) is well inside of a stack frame and the fact that the caller currently builds the argument as a string[] is an implementation detail that the test/tester shouldn't need to care about. Working with List<T> in the unit test is convenient and correct for the test/tester. IOW, they shouldn't need to know the implementation detail and have to pass in a string[].
string[] attrNames = new string[] { "foo" };
using (RecordExpectations recorder = new RecordExpectations())
{
   obj.RemoveAttributes(attrNames);
   recorder.CheckArguments(attrNames);
}

This code works just fine but it isn't obvious or convenient.

Thanks,

Darin
asked by Darin_Creason (3.5k points)

1 Answer

0 votes
Hi,
You are probrably right, we should also support this scenario.
Thanks for reporting this, I have added this to our future features.
answered by scott (32k points)
...