Could someone explain why both tests using the latest versions of Moq and Rhino.Mocks frameworks fail complaining that Bar is not a virtual/overridable method:
public interface IFoo
{
string Bar();
}
public class Foo : IFoo
{
public string Bar()
{
return "Bar";
}
}
[TestMethod]
public void MoqTest()
{
var foo = new Mock<Foo>();
foo.Setup(f => f.Bar()).Returns("abc");
Assert.AreEqual("abc", foo.Object.Bar());
}
[TestMethod]
public void RhinoTest()
{
var foo = new MockRepository().PartialMock<Foo>();
foo.Expect(f => f.Bar()).Return("abc");
foo.Replay();
Assert.AreEqual("abc", foo.Bar());
}
If I declare Bar method as virtual both tests pass. I don't understand why I have to declare Bar as virtual. Isn't it already virtual? It comes from the interface.