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
Hi

I would like to see some new expectation methods like
ExpectNoCall(methodName)-->for methods
ExpectNoSet(propertyName)-->for props
ExpectNoGet(propertyName)-->for props

i know i could do with other ways right now now like checking the CalledCounter but that required MockManager.Init(true) or
set Mock.Strict=true but is going to be that for all the members.
Anyway it would be nice to have some expectations like the one i describe above

Regards
asked by tolisss (28.8k points)

2 Answers

0 votes
Hi,

These seem like a good idea, we will see when we can add them in.
In the meantime, here is a quick way to do this:
ExpectNoCall(methodName)

can be done as follows:
AlwaysThrow(methodName,new VerifyException("methodName should not be called"));


This way has the avantage of enabling you to mock the first few calls. (using ExpectSetAndAlwaysThrow and ExpectGetAndAlwaysThrow you can do the same with properties)

i know i could do with other ways right now now like checking the CalledCounter but that required MockManager.Init(true)


:idea: Another way is to mock the type and then use mock.GetCallCount(methodName);
Once a type is mocked, its calls are automaticlly monitored, so there is no need to call MockManager.Init(true) :)

I hope this helps
answered by scott (32k points)
0 votes
Hi,
:D This feature has been implemented in TypeMock version 2.2, using Strict on a method as follows:

mock.MethodSettings(methodName).IsStrict = true;


For more information see the Arbitrary Calls topic in the User Guide.
answered by richard (3.9k points)
...