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
0
votes
1 answer

How to test a controller which updates what was posted to it

This seems really simple, but I can't seem to get it to work. I want to unit test my controller's assign action. It takes a IEnumerable(Of Integer) which represent the ID's of all the objects to assign. Here's the code I've written, I'm getting an…
just.another.programmer
  • 8,579
  • 8
  • 51
  • 90
0
votes
0 answers

Unit Testing rhino mocks function(byRef byRef)

I have a function TryGetValues that receives a TKey and ByRef a TValue, and I need when I mock this function to return me something. I need the value of TValue because later in the method I'm testing I'm going to need this. The way I use to test it…
juan
  • 1
  • 1
0
votes
1 answer

RhinoAutoMocker: generate different objects for some type

I've started using RhinoAutoMocker and I was wondering if someone could give me hand with a problem I'm facing. I've got the following constructor (exposed by the object I want to test): public class MyViewModel{ public MyViewModel(ICommand cmd1,…
Luis Abreu
  • 4,008
  • 9
  • 34
  • 63
0
votes
1 answer

can I use dynamic to redirect HttpContext.Current.Request?

I'm using RhinoMocks for testing. It's not good at redirecting statics; I've considered using another library like the successor to Moles (edit: I guess the Fakes tool is only available in VS2012? that stinks) or TypeMock, but would prefer not to.…
jcollum
  • 43,623
  • 55
  • 191
  • 321
0
votes
1 answer

Mocking static methods in c# using Rhino Mock

What is the best approach for mocking out a static class in c#. For instance: String appPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; I want to mock this but will need to wrap it in a class with an interface, what is the…
user101010101
  • 1,609
  • 6
  • 31
  • 52
0
votes
1 answer

How to replace the execution of a method with RhinoMocks

Can anyone please explain why in RhinoMocks this code still ends up executing the native SomeVirtualMethod? var repository = MockRepository.GenerateStub(null, null); repository.Stub(x => x.SomeVirtualMethod()).Return(new…
joshcomley
  • 28,099
  • 24
  • 107
  • 147
0
votes
2 answers

Mocking File calls with Rhino Mock

Is it possible to mock out File calls with rhino mock example: private ServerConnection LoadConnectionDetailsFromDisk(string flowProcess) { var appPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; var bodyFile =…
user101010101
  • 1,609
  • 6
  • 31
  • 52
0
votes
3 answers

RhinoMocks: IList Stub doesn't add items to the list after it's been stubbed

I have something that looks like the following: var someList = MockRepository.GenerateStub>(); someList.Add(MockRepository.GenerateStub()); The list gets created as a proxy correctly. However, whenever I try to add an…
Joseph
  • 25,330
  • 8
  • 76
  • 125
0
votes
1 answer

Rhino Mock AAA expectation inside of expectation

Is it possible to mock the following situation, using Rhino Mock AAA syntax: // Interface interface IFoo { void ExecuteFoo( Expression action ); void Increment(out int value); // value++ } // Situation to mock: var foo = new…
Joanna
  • 81
  • 3
0
votes
1 answer

Rhino mocks exception with CompositionContainer

[TestFixture] public class UnitListViewModelTests { private CompositionContainer _container; private INHDataService _nhDataService; private INHUnitOfWork _nhUoW; [SetUp] [TestCase] public void create_container() { …
nakiya
  • 14,063
  • 21
  • 79
  • 118
0
votes
1 answer

Correctly Unit Test Service / Repository Interaction

I have a method CreateAccount(...) that I want to unit test. Basically it creates an Account Entity and saves it to the DB, then returns the newly created Account. I am mocking the Repository and expecting an Insert(...) call. But the Insert…
mxmissile
  • 11,464
  • 3
  • 53
  • 79
0
votes
1 answer

How do I capture the value of a Stream property using Rhino Mocks?

[TestClass] public class FooTests { [TestMethod] public void TestFoo() { var fooMock = MockRepository.GenerateMock(); // MUT FooUser.Run(fooMock); var stream = fooMock.Content; …
Kevin Driedger
  • 51,492
  • 15
  • 48
  • 55
0
votes
1 answer

Trying to use Rhino Mocks in VS2010 -- tests don't run

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(); …
Andrei
  • 261
  • 4
  • 11
0
votes
2 answers

Using Mocks with multiple scenarios in NBehave

I'm using NBehave to write out my stories and using Rhino Mocks to mock out dependencies of the System(s) Under Test. However I'm having a problem resetting expected behaviour in my mock dependencies when moving from one scenario to the next. I only…
0
votes
1 answer

Beginners Test the return of a metod

I've just began to work with Rhino-Mock, and I would like to test a basic method who check if pseudo and password is not null... Here is my test method: public void ValidateLoginTest() { // Arrange var stubConnectionToTfs =…
Pierpowl
  • 299
  • 4
  • 15