tagged [rhino-mocks]

Rhino Mocks: How to stub a generic method to catch an anonymous type?

Rhino Mocks: How to stub a generic method to catch an anonymous type? We need to stub a generic method which will be called using an anonymous type as the type parameter. Consider: ``` interface IProg...

31 May at 10:47

How to Mock a Static Singleton?

How to Mock a Static Singleton? I have number of classes I've been asked to add some unit tests to with Rhino Mocks and having some issues. First off, I know RhinoMocks doesn't allow for the mocking o...

12 Jan at 17:21

Rhino Mocks - Using Arg.Matches

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 ...

24 Jan at 23:9

How to mock a method call that takes a dynamic object

How to mock a method call that takes a dynamic object Say I have the following: And I have the following code that I want to test: How would I mock this call? Using Moq, I tired doing this: ``` var se...

5 May at 06:24

Rhino Mocks AssertWasCalled (multiple times) on property getter using AAA

Rhino Mocks AssertWasCalled (multiple times) on property getter using AAA I have a mocked object that is passed as a constructor argument to another object. How can I test that a mocked object's prope...

What does Rhino Mocks mean by "requires a return value or an exception to throw"?

What does Rhino Mocks mean by "requires a return value or an exception to throw"? When mocking a call to a WCF Service, I get the following error: > Method 'ICustomerEntities.GetCustomerFromPhoneNumbe...

16 Apr at 14:59

How to set the Expect call to check that a method is not called in Rhino Mocks

How to set the Expect call to check that a method is not called in Rhino Mocks Using Rhino Mocks, how do I ensure that a method is not called while setting up the Expectations on the mock object. In m...

3 Feb at 11:41

Rhino mocks - does this test look sensible?

Rhino mocks - does this test look sensible? I have just crafted the following test using Rhino mocks. Does my test look valid and make sense to those more experienced with mocking? I am a a little con...

14 Dec at 16:51

Rhino Mocks - AssertWasCalled: How to improve unclear diagnostic message when incorrect arguments

Rhino Mocks - AssertWasCalled: How to improve unclear diagnostic message when incorrect arguments IMHO, Rhino Mocks produces an unclear diagnostic message when AssertWasCalled is used in order to veri...

26 Feb at 14:24

Simulating CancellationToken.IsCancellationRequested when unit testing

Simulating CancellationToken.IsCancellationRequested when unit testing I would like to test a task that is supposed to run continuously until killed. Suppose the following method is being tested: ``` ...

How can I use Rhino Mocks to inspect what values were passed to a method

How can I use Rhino Mocks to inspect what values were passed to a method I'm new to mocking, and I'm having a hard time solving an issue with UnitTesting. Say I have this code: ``` public class myClas...

12 Jul at 13:36

How to Construct IdentityResult With Success == true

How to Construct IdentityResult With Success == true I have a class with Microsoft.AspNet.Identity.UserManager injected, and I want to expect the userManager.CreateAsync(user, password) method to retu...

9 Oct at 01:49

Stub one method of class and let other real methods use this stubbed one

Stub one method of class and let other real methods use this stubbed one I have a `TimeMachine` class which provides me current date/time values. The class looks like this: ``` public class TimeMachin...

23 Dec at 20:35

Mocking GetEnumerator() method of an IEnumerable<T> types

Mocking GetEnumerator() method of an IEnumerable types The following test case fails in rhino mocks: ``` [TestFixture] public class EnumeratorTest { [Test] public void Should_be_able_to_us...

24 Dec at 13:36

RhinoMocks - Fetching parameters of called functions

RhinoMocks - Fetching parameters of called functions Using RhinoMocks - can I fetch the parameters of a called function? I mean; can I get some of the unknown parameters from the function call out? I ...

13 Jan at 19:43

Stubbing a Property get using Rhino Mocks

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 th...

23 May at 12:16

What are the real-world pros and cons of each of the major mocking frameworks?

What are the real-world pros and cons of each of the major mocking frameworks? > see also "[What should I consider when choosing a mocking framework for .Net](https://stackoverflow.com/questions/64262...

23 May at 12:1

Best Practices of Test Driven Development Using C# and RhinoMocks

Best Practices of Test Driven Development Using C# and RhinoMocks In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more testa...

9 Sep at 23:31

Raising events from a mock/stub using Rhino Mocks

Raising events from a mock/stub using Rhino Mocks How can I raise an event from a mock/stub using Rhino Mocks? I've found some answers to this question on the web, but they all seem to use the Record/...

20 Jun at 00:8

How do I mock IQueryable<T>

How do I mock IQueryable I am creating a repository that exposes IQueryable. What is the best way to mock this out for my unit testing? Since I am using RhinoMocks for the rest of my mock objects, I t...

12 Feb at 04:39

Quick Rhinomocks Help

Quick Rhinomocks Help Can someone take a look at this code and tell me if there's any obvious reason it shouldn't be working? When service.getResponse is called within my code the mocking framework on...

16 Nov at 22:45

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

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 ha...

How to Mock a Task<> Result?

How to Mock a Task Result? I'm setting up some unit tests and using Rhino Mocks to populate the object being tested. One of the things being mocked is a `Task`, since the logic being tested includes a...

Castle DynamicProxy - Failure when creating proxy involving a GTP used as a GTR

Castle DynamicProxy - Failure when creating proxy involving a GTP used as a GTR OK, now I'm really confused. I originally had [this problem](https://stackoverflow.com/questions/4382624/cant-get-rhinom...

Render a View during a Unit Test - ControllerContext.DisplayMode

Render a View during a Unit Test - ControllerContext.DisplayMode I am working on an ASP.NET MVC 4 web application that generates large and complicated reports. I want to write Unit Tests that render a...