Moq allows developers to mock protected members. I searched for the same functionality in Rhino.Mocks , but could not find it.
Here is an example from Moq Quick Start to trick a protected method.
// at the top of the test fixture using Moq.Protected() // in the test var mock = new Mock<CommandBase>(); mock.Protected() .Setup<int>("Execute") .Returns(5); // if you need argument matching, you MUST use ItExpr rather than It // planning on improving this for vNext mock.Protected() .Setup<string>("Execute", ItExpr.IsAny<string>()) .Returns(true);
Let me know if I pursue something that does not come out.
moq mocking rhino-mocks
Vadim
source share