0

I have a unit test that works just fine when it is hitting a real object that hits teh real data storage. Something like that:

    [TestMethod]
    public void ATest()
    {
        var p = new Provider();

        var data = p.GetData();

        ...

    }

This test gets executed in all modes, gets the data back and does everything that is exected from it. Now, say I want to mock the provider using Rhino Mocks. Provider class implements IProvider. So I go and write something like this:

    [TestMethod]
    public void ATest()
    {
        var p = MockRepository.GenerateStub<IProvider>();

        ...

        var data = p.GetData();

        ...

    }

But now when I try to debug this test, it doesn't work. At all. I mean, I put a breakpoint on the first line of this method (on the '{' itself) and it is not being hit. Kind of weird...

I am all new to Rhino Mocks, maybe I am missing something obvious?

Andrei
  • 261
  • 4
  • 11

1 Answers1

0

You didn't define a return value for the GetData call on the mock. Try something like this:

p.Stub(s => s.GetData()).Return(testData);
Richard Banks
  • 12,456
  • 3
  • 46
  • 62
  • I did. I just skipped it from the code sample as I was trying to highlight the issue I am having: whenever I add Rhino Mocks stuff into a test method, it stops executing. And I can't figure out why... No errors or warnings from compiler. Created new test project in my solution, put the code there -- still doesn't work. – Andrei May 17 '12 at 16:59
  • As a thought, maybe try the same test using NSubstitute for the mock instead of Rhino. Both use the castle dynamic proxy under the hood so it would help isolate wether it's Rhino that's the problem or the dynamic proxy. – Richard Banks May 20 '12 at 11:11
  • Upgrade to Resharper 6 (from 5) fixed the issue :) – Andrei Dec 22 '12 at 21:57
  • Good to know it's all fixed. Strange that the R# test runner was the problem though. – Richard Banks Dec 28 '12 at 06:29