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
Here is a test that fails after property a.X is used as an argument to a method in a WhenCalled() call:

[ img ]
Code for the above: http://pastebay.com/pastebay.php?dl=73535

After the WhenCalled() call, a.X loses its value and loses its ability to be assigned a new value. Is this a bug? If not, why does Isolator do that to properties used as arguments to methods in WhenCalled() calls?

I am aware of doing this:

[ img ]

But would prefer to not have to do that because an extra variable in a test adds complexity to a test.
asked by Neil (27.7k points)

2 Answers

0 votes
Hi Neil,

as far as I know that last example you posted is the proper (and probably the only) way to do it.

Its a technical thing about the Isolator not being to distinguish between the call you want to fake (a.Method()) and the call to the property.

IIRC in most cases it would output an error when you do that, and i would expect it to do the same here. and not mess the property behavior itself.

:?: regarding the complexity, given that that isolator completely ignores arguments passed into a faked method, what was your intention when passing it the a.X value? you could just as well pass it a 0. (making your test a little simpler)
answered by error (6.6k points)
0 votes
Hi Lior,

Thank you for reminding me about Isolator ignoring values which prompted me to remember about AndArgumentsMatch().

This is what I had intended:

[ img ]
answered by Neil (27.7k points)
...