Grzenio
Grzenio

Reputation: 36689

Strict Mocks using AAA syntax of Rhino Mocks

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

Answers (5)

Frank Wu
Frank Wu

Reputation: 79

Try the new syntax

MockRepository.GenerateStrictMock; MockRepository.GenerateMock;

Upvotes: 1

Tony Hou
Tony Hou

Reputation: 1384

MockRepository.GenerateStrictMock; generates a strick mock.
MockRepository.GenerateMock; generates a Dynamic Mock.

Upvotes: 0

Ralph Willgoss
Ralph Willgoss

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

Grzenio
Grzenio

Reputation: 36689

I Rhino Mocks 3.6 we finally have: MockRepository.GenerateStrictMock<T>(). GenerateMock does not create strict mocks.

Upvotes: 3

Mark Seemann
Mark Seemann

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

Related Questions