rhino-mocks

Is there an in-memory provider for Entity Framework?

I am unit testing code written against the ADO .NET Entity Framework. I would like to populate an in-memory database with rows, and make sure that my code retrieves them properly. I can mock the Entity Framework using Rhino Mocks, but that would not be sufficient. I would be telling the query what entities to return to me. This would ne...

What is the Use of Repeat.Any() in Expect.Call while using Rhino Mocks Test framework

When I use Repeat.Any() it doesn't show any error though I don't call GetMood() Method ,but if i don't use n doesn't call GetMood then it shows Excpetion of type ExpectationViolationException.Can somebody tell me what is the use of repeat.any(). MockRepository mocks = new MockRepository(); IAnimal animal = mocks.DynamicMock<IAnimal>();...

How do I stub the HttpSessionState in MVC RC1 with rhino mocks?

I'm trying to take advantage of the recent ControllerContext refactoring in asp.net mvc rc1. I should be able to stub the session rather simply but I keep getting a System.NullReferenceException on line 2 when running the following code: var mockContext = MockRepository.GenerateStub<ControllerContext>(); mockContext.Stub(x => x.HttpCont...

How to mock the property which returns the list object - In rhino mock

Interface IView { List<string> Names {get; set;} } public class Presenter { public List<string> GetNames(IView view) { return view.Names; } } var mockView = MockRepository.GenerateMock<IView>(); var presenter = new Presenter(); var names = new List<string> {"Test", "Test1"}; mockView.Expect(v => v.Names).Return(name...

How can I avoid large multi-step unit tests?

I'm trying to unit test a method that performs a fairly complex operation, but I've been able to break that operation down into a number of steps on mockable interfaces like so: public class Foo { public Foo(IDependency1 dp1, IDependency2 dp2, IDependency3 dp3, IDependency4 dp4) { ... } public IEnumerable<int>...

Rhino Mock and Mock in general

Is there any place or any one out there who can explain how this works in plain English instead of "defining terms in terms of themselves"? ...

Is it possible to set a property value of object during Expect.Call in RhinoMocks?

I have a method that should only be called when a property of a specific object is set to false. This is its initial value. After the first call, the property is set to true, ensuring that the call is only ever made once. However, when I mock the class that performs this change, the mock object does not change the property of the underl...

Mock abstract class default behaviour with Rhino

I'm pretty new to mocking so this might be something I'm just not picking up on yet, but I can't find a good example anywhere. I'm trying to assert that by default, any class that inherits from my abstract class will instantiate a collection in the constructor. Here's the abstract class: public abstract class DataCollectionWorkflow : ...

Is there anything like RhinoMocks in Java?

What would be the closest resemblance? ...

Rhino mocks change behaviour of stubs

Can I change the behaviour of a stub during runtime? Somthing like: public interface IFoo { string GetBar(); } [TestMethod] public void TestRhino() { var fi = MockRepository.GenerateStub<IFoo>(); fi.Stub(x => x.GetBar()).Return("A"); Assert.AreEqual("A", fi.GetBar()); fi.Stub(x => x.GetBar...

Using Rhino Mocks how can I set a property of a parameter for a Mocked method

Using the new Rhino Mocks 3.5 Arrange/Act/Assert (AAA) Testing style, I'm having problems writing a test. I have a method that calls a method on a repository class. ActivateFoo, where my Foo object has an IsActive property. The result of the ActivateFoo object should change the property. Here is sample code: [TestMethod] public void ...

Why does RhinoMock not fail this test?

I have a class that acts like this at the moment: public class MyClass { public void Method1(){ if (false) { Method2(); } } public void Method2(){ //do something here } } So Method2 is never called (my code looks a bit different but I have this if-clause that evaluates to false and...

Rhino Mocks - How to assert a mocked method was called n-times?

How can i assert that a method on a mocked object was called exactly called n-times? Here is the code snippet from a controller action, i like to test: for (int i = 0; i <= newMatchCommand.NumberOfMatchesToCreate; i++) { serviceFacade.CreateNewMatch("tester", Side.White); } The "service facade" object is the (strict) mock and wil...

Mocking and HttpContextBase.get_User()

I want to mock the User property of an HttpContext. I'm using Scott Hanselmans MVCHelper class and RhinoMocks. I have a unit test that contains code, like this: ... MockIdentity fakeId = new MockIdentity("TEST_USER", "Windows", true); MockPrincipal fakeUser = new MockPrincipal(null, fakeId); using (mocks.Record()) { Expect.Call(f...

What are the capabilities of Moq and Rhino.mocks?

I cannot find a specific feature-by-feature comparison of Moq and Rhino. All the questions are "which do you like better and why", or "here's how you do a simple mock in rhino and how it's done in moq". I cannot find a deep comparison anywhere. I'm aware of the syntax differences, I'm not looking for answers about that. I am looking ...

Rhino Mocks: "Verify" vs. "Assert"

When using Rhino Mocks, when is it appropriate to use "VerifyAll" and when should I do "Asserts"? ...

How to use Rhino Mocks to Mock an HttpContext.Application

I'm new to Mocking frameworks and have started using RhinoMocks to assist with my MVC App Unit Testing. I'm using Scott Hanselmanns MVC Mock Helper to assist in mocking the HttpContext. I've succesfully (after some time) mocked some of what I need but have come unstuck when it comes to the Application property of the HttpContext. In my...

Equivalent of LastCall.IgnoreArguments in EasyMock

I have used Rhino.Mocks extensively currently writing some tests in Java using EasyMocks. However I was unable to pull out a LastCall.IgnoreArguments() Rhino.Mocks equivalent in EasyMocks. How do I use Easy Mocks to return a value irrespective of the arguments in the method. For example: public interface ISoothSayer { String SayS...

How do you mock UnitOfWork from Rhino.Commons?

My application is using Rhino.Commons - NHRepository and UnitOfWork. I like the With.Transaction() syntax for transactions and have been using it for some time. But I ran into a problem - how do I mock a UnitOfWork for testing? Especially this is causing trouble for me: With.Transaction(() => Repositories.TwinfieldSpooler.Update(spool...

Rhino Mocks: Mocked method returns null

I'm trying to mock a data repository object but after setting an expectation on my MockRepository, it returns null every time. My code is as follows: [Test] public void GetById_NotNull() { Person expectedPerson = new Person() { Id = 1, Name="Jon"}; MockRepository MockRepository = new MockRepository(); ...