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
why do I get IndexOutOfRangeException in this code?

Isolate.Verify.WasCalledWithArguments(() => fakeSite.Files.Add((string)"", (Stream)fileStream, true))
                .Matching(args => (
                    ((string)args[0]).Equals(fakeFullUrl + "/" + filename) &&
                    (args[1] != null) &&
                    (bool)args[2]
                    ));
asked by tomasr (600 points)

1 Answer

0 votes
Hi,

Verify with custom matching arguments doesn't support chains at the moment. The message you received is a bug, Verify should have warned about the chain.

The solution is simple, all needed is to store the object on which we're verifying before the call to verify:
var files = fakeSite.Files;

Isolate.Verify.WasCalledWithArguments(() => files.Add((string)"", (Stream)fileStream, true)) 
                .Matching(args => ( 
                    ((string)args[0]).Equals(fakeFullUrl + "/" + filename) && 
                    (args[1] != null) && 
                    (bool)args[2] 
                    ));


I've added a bug about the message. I'm also adding to our backlog chains support to custom verify.

Best Regards,
Elisha
Typemock Support
answered by Elisha (12k points)
...