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
I've starting using the AAA API and I like it. One thing that I haven't been able to figure out is how to fake different overloads of the same method so that they return different results. In one case, I want the first overload to throw and exception and then verify that the second overload was called with specific parameters. I was trying to do it this way:

Isolate.WhenCalled(() => class.SomeMethod(parm1)).WillThrow(new Exception("Exception for test."));
Isolate.WhenCalled(() => class.SomeMethod(parm1, parm2)).WillReturn(fakeObject);

... execute code that calls class.SomeMethod(parm1) and, when the exception is caught, call class.SomeMethod(parm1, parm2)...

Verify.WasCalledWithExactArguments(() => class.SomeMethod(parm1, parm2));

What happens when I run this code is that the call to the first overload - SomeMethod(parm1) - returns the fakeObject that I specified as the expected return object for the second method.

I can do this with the Natural Mocks using the following code:

Exception expectedException = new Exception("Exception for test.");

using (RecordExpectations recorder = Record)
    class.SomeMethod(parm1, parm2);

.. verification here.

Is there a way to do this with AAA?
asked by RonRatz (3k points)

1 Answer

0 votes
Hi RonRatz,

Unfortunately, there currently no support for method overloads in AAA :( We are aware this is a feature many users want and we're working on putting it in an upcoming version.

answered by doron (17.2k points)