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
Lately, I've been getting bitten by "Refactor > Rename". This is a radical request, but will TypeMock ever move from string-based member reference?

From:
someMock.ExpectAndReturn("GetSomething", 5);

To:
someMock.ExpectAndReturn(someMock.Object.GetSomething(), 5)

I've been playing with a dynamic mocking framework called Rhino Mock, and its concept is very interesting.

Expect.On(someMock).Call(someMock.GetSomething()).Return(5)
asked by Dog_Soldier (3.1k points)

3 Answers

0 votes
Hi,
Thanks for the pointer, we are actually quite aware of this.

The Rhino Mock has actually taken the syntax from nmock2 and easymock. Although this feature will help with public methods, there is no way to support private and protected methods (The code won't compile) with is one of TypeMocks abilities, so we can implement this for public methods only and leave the regular synatx for non public ones.
In any case you will still have problems with changing the signiture (adding an argument).
answered by scott (32k points)
0 votes
Lately, I've been getting bitten by "Refactor > Rename". This is a radical request, but will TypeMock ever move from string-based member reference?

From:
someMock.ExpectAndReturn("GetSomething", 5);

To:
someMock.ExpectAndReturn(someMock.Object.GetSomething(), 5)

...


Hi Dog_Soldier,

perhaps Studio 2005 will help you. Refactor->Rename can also rename in strings. BTW: In this case you'll have to include testing projects into your solution so Rename can find it (independent from string-rename or method-rename).
Remember: The same problem occurs if you do reflection (which I do often within nunit cause its an easy way to setup the private's of a class) as reflection methods need method names in strings as well. As scott points out the main problem is with private, protected, internal etc.. And from my praxis I can say you need to test some of those non-public too. That's tester's life...
answered by mknaup (8.5k points)
0 votes
:idea: TypeMock.NET version 3.5 now supports Natural TypeMocks™ that are Strongly Typed and thus supports Compile Time Checks and Refactoring.
answered by scott (32k points)
...