Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

New expectations

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 Jan 28, 2005 by tolisss (3,660 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 Jan 29, 2005 by scott (29,080 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 Mar 22, 2005 by richard (3,900 points)
...