Questions tagged [rhino-mocks-3.5]

Questions related to Rhino-Mocks version 3.5 and above. The AAA syntax was introduced in Version 3.5.

Rhino Mocks 3.5 introduces some new concepts, mostly by building upon the language features of C# 3.0. Users on the 2.0 platform need not worry, there are enough goodies for them as well (inline constraints, for example).

Rhino-Mock 3.5 Documentation

48 questions
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
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
9
votes
1 answer

With Rhino Mocks how to stub a method that makes use of the params keyword?

I am attempting to setup an expectation on a repository. The method makes use of the params keyword: string GetById(int key, params string[] args); The expectation I have setup: var resourceRepo =…
ahsteele
  • 26,243
  • 28
  • 134
  • 248
5
votes
2 answers

Rhino - Mocking classes and not overriding virtual methods

If I'm mocking a class, like below, is there any way I can get the mock to not override a virtual method? I know I can simply remove the virtual modifier, but I actually want to stub out behavior for this method later. In other words, how can I get…
Adam Rackis
  • 82,527
  • 56
  • 270
  • 393
4
votes
1 answer

Rhino Mock Parameter Inspection ... Is There a Better Way?

I'm using Rhino Mocks 3.5 to mock a service method call which takes 2 parameters and I want to make sure a propery on an object is being set correctly. // Method being tested void UpdateDelivery( Trade trade ) { trade.Delivery = new DateTime(…
KornMuffin
  • 2,887
  • 3
  • 32
  • 48
3
votes
2 answers

Rhinomocks - Mocking delegates

public interface IServiceInvoker { R InvokeService(Func invokeHandler) where T : class; } public class MediaController : Controller { private IServiceInvoker _serviceInvoker; public MediaController(IServiceInvoker…
Abhilash
  • 121
  • 1
  • 7
3
votes
1 answer

NUnit with Rhino Mocks exception: Why is it throwing this exception?

I'm getting an exception that really makes no sense to me whatsoever. I have an Expect call for a method that takes 3 arguments into it: The types are called CallContext, IDal, and List. NUnit throws me 2 exceptions: One for not expecting a method…
Corey Adler
  • 15,897
  • 18
  • 66
  • 80
3
votes
1 answer

Preferred way to mock/stub a system resource like System.Threading.Mutex

I have a c# class that uses a Mutex to control access to a global shared resource. The Mutex is not assigned unless the shared resource is created. I'm using a partial mock of the class to isolate testing of certain methods that grab the mutex, do…
Brian Colwell
  • 79
  • 2
  • 5
3
votes
2 answers

Rhino Mocks - Stub a Singleton

I have a Singleton that is accessed in my class via a static property like this:OtherClassNotBeingTested.Instance.SomeInstanceMethod() I would like to test my class with out making one of these objects. Is there a way for RhinoMocks to return a…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
2
votes
1 answer

RhinoMocks: AssertWasCalled doesn't work on Stub

I'm trying to assert with RhinoMocks that a certain property setter was called. But it's not working as expected. The following simplified example illustrates the problem. Consider this interface: public interface IMyInterface { string…
G S
  • 35,511
  • 22
  • 84
  • 118
2
votes
1 answer

AssertWasCalled and Stub with method that has ref parameter

I have problems with stubbing a method with a ref parameter. I want to stub that method for a certain input value and check that it was called. My attempt: // Variables needed - can be skipped var activity =…
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
2
votes
1 answer

check that property setter was called

I have a class I am unit testing and all I want to do is to verify that the public setter gets called on the property. Any ideas on how to do this? I don't want to check that a value was set to prove that it was called. I only want to ensure that…
user2309367
  • 317
  • 2
  • 8
2
votes
4 answers

Handling Multiple Mocks and Asserts in Unit Tests

I currently have a repository that is using Entity Framework for my CRUD operations. This is injected into my service that needs to use this repo. Using AutoMapper, I project the entity Model onto a Poco model and the poco gets returned by the…
SetiSeeker
  • 6,482
  • 9
  • 42
  • 64
2
votes
2 answers

How to return value from a method by a specified condition in RhinoMocks?

How to emulate the following behaviour using RhinoMocks? The tested method invokes ReceivePayment method on an interface. public void TestedMethod(){ bool result = interface.ReceivePayment(); } Interface has the CashAccepted…
EngineerSpock
  • 2,575
  • 4
  • 35
  • 57
2
votes
1 answer

Why does RhinoMocks behave differently in VB & C#?

I have test code similar to this: Public Interface IDoSomething Function DoSomething(index As Integer) As Integer End Interface Public Sub ShouldDoSomething() Dim myMock As IDoSomething = MockRepository.GenerateMock(Of…
David Osborne
  • 6,436
  • 1
  • 21
  • 35
1
2 3 4