Reputation: 36689
Is it possible to create a "strict" mock using the new AAA syntax of Rhino Mocks? The issue I am seeing is that the library I am mocking often returns null as a valid return value (which I handle in my function), so using the default mock I can never be sure if I tested all paths or I forgot to set some expectations.
Upvotes: 4
Views: 1752
Reputation: 79
Try the new syntax
MockRepository.GenerateStrictMock; MockRepository.GenerateMock;
Upvotes: 1
Reputation: 1384
MockRepository.GenerateStrictMock; generates a strick mock.
MockRepository.GenerateMock; generates a Dynamic Mock.
Upvotes: 0
Reputation: 12183
They functionality has changed and GenerateMock() doesn't return a strict mock. StrictMock is still available for use. Just not under the new syntax.
Ayende talks more about how CreateMock is deprecated, replaced by StrictMock here.
Note:
Added new answer so people can easily find Ayende thoughts on the change.
Upvotes: 0
Reputation: 36689
I Rhino Mocks 3.6 we finally have: MockRepository.GenerateStrictMock<T>()
. GenerateMock does not create strict mocks.
Upvotes: 3
Reputation: 233477
MockRepository.GenerateMock<T>()
should return a 'strict' mock - as opposed to MockRepository.GenerateStub<T>()
, but couldn't you just define an explicit method setup that returns null?
Upvotes: 1