rhino-mocks-3.5

Can I tell if a property has been accessed via Rhino Mocks

I have a property in an interface that I have mocked using Rhino Mocks. I want to know if it was accessed in my unit test. Is there a way to see if the property was accessed via Rhino Mocks? I found this code here but it does not seem to work: string name = customerMock.Name; customerMock.AssertWasCalled(x => {var ignored = x.Name;})...

How can I set a value to a Rhino Mocked object?

I have a scenario like this: form = MockRepository.GenerateMock<IAddAddressForm>(); mediator = new AddAddressMediator(form); The mediator is the real object under test and needs to be able to set values for the "form" object. But the only way I can see to set values for the form object is like this: form.Stub(x=>x.FirstName).Ret...

Rhino Mocks error - "Invalid call, the last call has been used or no call has been made"

I am stumped. 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 calling a virtual (C#) / Overridable (VB) method).. I am trying to use only Rhino...

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 stub when the getter for the static property Instance is called? To be clearer, here is the...

RhinoMocks Testing callback method

Hi All I have a service proxy class that makes asyn call to service operation. I use a callback method to pass results back to my view model. Doing functional testing of view model, I can mock service proxy to ensure methods are called on the proxy, but how can I ensure that callback method is called as well? With RhinoMocks I can tes...

Verify an event was raised by mocked object

In my unit test how can I verify that an event is raised by the mocked object. I have a View(UI) --> ViewModel --> DataProvider --> ServiceProxy. ServiceProxy makes async call to serivce operation. When async operation is complete a method on DataProvider is called (callback method is passed as a method parameter). The callback method t...

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 call that happened where the types are CallContext, System.Object, and List, and one fo...

Rhino Mocks and Visual Studio: How do I fix this error?

I'm having another fun problem with Rhino Mocks. Can anyone answer this one: Here's the call that I'm making in my code: Expect.On(this.mockDal).Call(this.mockDal.SaveObject(entry)).IgnoreArguments(); mockDal is mocking something of type Dal, and it's SaveObject method's signature is this; void SaveObject(object obj); Visual Stud...

Is "Record" Deprecated in Rhino Mocks

The latest version of Rhino mocks supports Arrange, Act Assert methodology. Does that mean that the record method that it used in previous version is deprecated? I thought it was (deprecated), but as I was reading "The Art of Unit Testing" he uses the Record method when he introduces Rhino Mocks. So now I am not so sure.... Any one k...

How to mock arbitrary behavior with Rhino Mocks?

Hi all, I'm trying to mock a data layer method. The method takes a string and two lists as arguments, and the method populates those lists from the results of a stored proc. Also, I'm still on C# 2.0 with VS2005, and I'm using Rhino Mocks 3.5 for .NET 2.0. If possible, it would be nice to use the AAA format. So yeah, all I want to do ...