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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes

I'm not sure what to make of this method. Since I get an error that the object passed in has to be a mocked object or specified in WhenCalled() routine, I'm not sure how to make use of this. Basically, I want to ensure that under the scenes, a method was called with the following parameters:

//managerMock is my mocked object

I want to verify that my code validates that all three were added as the result of a method call. How can I do this using WasCalledWithExactArguments?

asked by bmains (13.2k points)

3 Answers

0 votes

Due to a limitation, Isolator cannot verify against objects that were not faked (created using Fake.Instance(), or were set with a fake behavior using WhenCalled()) - is managerMock such an object? You can simply create it as a fake with the CallOriginal behavior to work around this.

Typemock Support
answered by doron (17.2k points)
0 votes

In this example, managerMock is a mock I created through Isolate.Fake, and I don't know how to use WasCalledWithExactArguments to verify that a method within the type managerMock is mocking has been called with an exact argument...

So you can't verify strings because they aren't actual mocked objects? I'm just trying to figure out the usefulness of this method.

answered by bmains (13.2k points)
0 votes
Hi Brian,

You can use AAA API to check that the three strings were called:
Isolate.WasCalledWithExactArguments(() => managerMock.AddProperty("LastName");

MockManager should be either created using Isolate.Fake.Instance, you can use Members.CallOriginal if you need the actual method code to be called or you need to set some expectation on the verified method:
// Set Expectation - not necessary IgnoreCall

// Do Something

// Assert Call Was Made
Isolate.WasCalledWithExactArguments(() => managerMock.AddProperty("LastName")

The error message does not relate to the parameter unless you have another method call inside the verify block - which we currently do not support:
// Not supported -- using another call inside the verify block 
Isolate.WasCalledWithExactArguments(() => managerMock.AddProperty(SomeClass.GetSpecialNameString())
answered by dhelper (11.9k points)