Questions tagged [rhino-mocks]

Rhino.Mocks is a dynamic mock object framework for the .NET platform. Rhino.Mock's purpose is to ease testing by allowing the developer to create mock implementations of custom objects and verify the interactions using unit testing.

Rhino.Mocks is a dynamic mock object framework for the .NET platform. Rhino.Mock's purpose is to ease testing by allowing the developer to create mock implementations of custom objects and verify the interactions using unit testing.

To get started, take a look at the useful manual full of examples for .NET version 3.5. For more information, see the wiki for Rhino.Mocks or the documentation (source code in GitHub).

Installation RhinoMocks can most easily be installed through its NuGet package.

Install-Package RhinoMocks 
1223 questions
23
votes
2 answers

Stubbing a Property get using Rhino Mocks

Using RhinoMocks, I am trying to Stub the getter value of a property. The property is defined as part of a Interface with only getter access. However I get the error "Invalid call, the last call has been used or no call has been made (make sure that…
Santhosh
  • 6,547
  • 15
  • 56
  • 63
23
votes
2 answers

RhinoMock : Mocks Vs StrictMocks Vs DynamicMocks

I understand the difference between a Mock and a Stub. But different types of Mocks in RhinoMock framework confuses me. Could someone explain the concepts of Mocks Vs StrictMocks Vs DynamicMocks in terms of RhinoMock framework. your answers are…
Eranga Dissanayaka
  • 1,930
  • 3
  • 24
  • 27
23
votes
3 answers

Rhino Mocks - mocking a method whose return value changes (even when passed the same parameter) with multiple calls

I'm looking to find out how I can mock a method that returns a different value the second time it is called to the first time. For example, something like this: public interface IApplicationLifetime { int SecondsSinceStarted…
AlexC
  • 1,646
  • 1
  • 14
  • 26
22
votes
1 answer

Rhino Mocks step-by-step tutorials

I realise that there exist some posts such as this one which have asked the same question. However, the links on the suggested page do not work (it simply takes me back to the blog homepage). I'm looking for a tutorial which does not have any…
user1173691
  • 443
  • 2
  • 6
  • 15
22
votes
5 answers

Rhino Mocks stubs and mocks are only good for interfaces?

Is it correct that Rhino Mocks stubs and mocks are only good for interfaces, not concrete classes? I spent quite a time trying to make this piece of code working. I did not expect the stubbed pubSubClient to always call Send method from the class.…
Dmitry Duginov
  • 547
  • 2
  • 4
  • 15
21
votes
2 answers

Multiple calls to a Rhino mocked method return different results

If I want to mock a class that returns a string that is used to determine whether while loop should continue (imagine read while string != null), how can I set the expectation. I have tried the following: provider.Reader.Expect(r =>…
Colin Desmond
  • 4,824
  • 4
  • 46
  • 67
20
votes
3 answers

Cannot create a Mock class for an internal type using Rhino Mocks

I am using Rhino Mocks as a mocking framework for unit testing. I have a class called Subject which is the class I want to test. It has a dependency on IStore. IStore is defined as follows: //internal interface : has InternalsVisible to both…
Santhosh
  • 6,547
  • 15
  • 56
  • 63
20
votes
2 answers

Rhino Mocks - Using Arg.Matches

I have a function I am mocking which takes an argument object as a parameter. I want to return a result based on the values in the object. I cannot compare the objects as Equals is not overriden. I have the following code: _tourDal.Stub(x =>…
Tristan
  • 313
  • 1
  • 2
  • 6
19
votes
8 answers

Is there any open source mocking framework resembling TypeMock?

TypeMock is too expensive for a hobbist like me :) Moq or the next version of RhinoMocks have no plans on listening to the profiling API, why is that? EDIT: This enables features such as: Mocking non-virtual methods and properties (!). Mocking…
gkdm
  • 2,375
  • 4
  • 21
  • 27
19
votes
4 answers

RhinoMock vs. TypeMock vs. NUnit's Mocking?

I am just starting to do Test Driven Development, and I am wondering the major differences between RhinoMock, TypeMock, and NUnit's built-in mocking? Any information would be greatly appreciated!
Dan Appleyard
  • 7,405
  • 14
  • 49
  • 80
19
votes
5 answers

Invalid call, the last call has been used or no call has been made

I am getting this error when I try to set a mock to have PropertyBehavior(): System.InvalidOperationException: System.InvalidOperationException: Invalid call, the last call has been used or no call has been made (make sure that you are…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
19
votes
6 answers

Mocking a Using with a FileStream

I have been trying to mock out a using with a file stream but have not been able to complete this and am unsure how to do it, I am using rhino mock. private Connection LoadConnectionDetailsFromDisk(string bodyFile) { //logic before using…
user101010101
  • 1,609
  • 6
  • 31
  • 52
18
votes
3 answers

How to create a stub with Moq

How do I creat a pure stub using Moq? With Rhino Mocks I did it like this: [TestFixture] public class UrlHelperAssetExtensionsTests { private HttpContextBase httpContextBaseStub; private RequestContext requestContext; private…
Brendan Vogt
  • 25,678
  • 37
  • 146
  • 234
18
votes
1 answer

How to change behaviour of stubs?

Can I change the behaviour of a stub during runtime? Something like: public interface IFoo { string GetBar(); } [TestMethod] public void TestRhino() { var fi = MockRepository.GenerateStub(); fi.Stub(x =>…
froh42
  • 5,190
  • 6
  • 30
  • 42
18
votes
3 answers

How do I combine two interfaces when creating mocks?

We are using Rhino Mocks to perform some unit testing and need to mock two interfaces. Only one interface is implemented on the object and the other is implemented dynamically using an aspect-oriented approach. Is there an easy way to combine the…
sduplooy
  • 14,340
  • 9
  • 41
  • 60
1 2
3
81 82