1

Following is a simple TestMethod which which passes successfully using ITestInterface

ITestInterface mockProxy = MockRepository.GenerateMock<ITestInterface>(); 

OR

ITestInterface mockProxy = MockRepository.GenerateStub<ITestInterface>();

Can someone help me which one to use in this specific scenario.

Following is TestMethod for testing a business layer method and x.Method is a Data Access Layer method.

[TestMethod]
public void TestMethod1()
{
    ITestInterface mockProxy = MockRepository.GenerateMock<ITestInterface>();

    ITestInterface mockProxy = MockRepository.GenerateStub<ITestInterface>();

    mockProxy.Stub(x => x.Method(Arg<int>.Is.Anything)).Return(10);

    var result = mockProxy.BusinessLayerMethod(10);

    Assert.AreEqual(10, result);
}
dcastro
  • 66,540
  • 21
  • 145
  • 155
Seema Gupta
  • 55
  • 1
  • 5

1 Answers1

1

Your scenario does not make sense at all. Surely the test method passed successfully, RhinoMocks works as expected ;) You just hard coded return value for a method to be 10 and then simply verifying whether a method call on either Mock/Stub returns this value, this is fine test case to test RhinoMocks itself but not any custom behaviour (in this case your DAL behaviour)

sll
  • 61,540
  • 22
  • 104
  • 156