I am writing some unit tests and I want to mock out a user hmGuid
. To do so I do the following.
string userGuidString = "b3830ce8-09aa-41ac-b759-d2af4388c706";
Guid hmGuid = Guid.NewGuid();
Isolate.WhenCalled(() => hmGuid.ToString()).WillReturn(userGuidString);
However when I do that I get the following error
No method calls found in recording block. Please check:
Are you trying to fake a field instead of a property? try to set field
Any help with this would be greatly appreciated. The ToString()
is pretty standard and I've been able to mock this out on other classes before
Disclaimer: i work at typemock
The problem with your test is not the ToString() method, it's that you are trying to modify the behavior of a Mscorlib
class, Guid
, and it's not supported for the moment, but it will be possible in the near future.
More information here.