I get the following error on this line:
session.Expect(s => s.Add("string", null)).IgnoreArguments().Return(SaveMockUser());
cannot convert from 'void' to 'Rhino.Mocks.RhinoMocksExtensions.VoidType'
SaveMockUser is defined as follows
private void SaveMockUser()
{
}
What am I doing wrong?
...
i have an abstract class and im trying to mock out events being attached to it using Rhino Mocks. Here a bit of the abstract class
public abstract class Download
{
public virtual event EventHandler<DownloadProgressEventArgs> DownloadProgress_Changed;
protected virtual void OnDownloadProgressChanged(DownloadProgressEventargs e)
...
I have a class with a dependency:
private readonly IWcfClient<ITestConnectionService> _connectionClient;
and I want to stub out this call:
_connectionClient.RemoteCall(client => client.Execute("test"));
This currently isn't working:
_connectionService
.Stub(c => c.RemoteCall(rc => rc.Execute("test")))
.Return(true);
Is t...
I don't get it - I've looked at the documentation, and I can't see what's wrong with this code:
var mocks = new MockRepository();
var repository = mocks.StrictMock<IRecipeRepository>();
IList<Recipe> recipes = new List<Recipe>();
recipes.Add(new Recipe { ID = 1, Name = "Fish" });
recipes.Add(new Recipe { ID = 2, Name = "Chips" });
// T...
lets say i have a background worker in a class that perform db query in a background thread.
i wanna test this class
so i mock my db and return some collection so far so good,
make sure my background worker called the do work
and than i wanna make sure that the finish also happened.
I've noticed that the test pass and fail randomly (...
I am having issues mocking an array with Rhino Mock, any direction would be great.
namespace Checks_Rhino_Mocks
{
public class Check
{
public Header header;
public Detail[] details;
}
public class Header
{
public string Number;
public decimal Amount;
}
public class Detail
...
I've implemented an ITimer interface because I want to write some tests around a class I'm building that utilizes the System.Timers.Timer class.
So the sequence goes when I call Timer.Start() some time later I expect the Elapsed event to occur.
However, for my test I want to mock out this behavior, because I don't want to wait a certai...
I'm new to Rhino Mocks, so I may be missing something completely.
Lets say I have an interface with has a half dozen properties:
public interface IFoo {
string Foo1 { get; } // Required non-null or empty
string Foo2 { get; } // Required non-null or empty
string Foo3 { get; }
string Foo4 { get; }
int Foo5 { get; }
int Foo6 {...
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...
I want to test the OnException, OnActionExecuted event of an MVC controller.
If I use mock like this:
var httpContext = MockRepository.GenerateMock<HttpContextBase>();
var request = MockRepository.GenerateMock<HttpRequestBase>();
httpContext.Expect(c => c.Request).Return(request).Repeat.AtLeastOnce();
r...
How would you check the parameters on a function that accepts a Dictionary?
IDictionary<string, string> someDictionary = new Dictionary<string, string> {
{"Key1", "Value1"},
{"Key2", "Value2"}
};
Expect.Call(delegate {someService.GetCodes(someDictionary);}).Constraints(...);
Basically, I want to verify that the parameter for GetC...
I have a piece of logic I want to test and it uses dependency injected interface with one (or more) void methods, example:
interface IMyService
{
void MethodA (MyComplexObject arg1, int arg2);
}
What I would want is to create a stub for this IMyService that would just record the method invocations of MethodA and I would later be a...
I am playing around with MonoDevelop 2.0 and Mono 2.4 in Ubuntu.
I have run into problems with extension methods not being available (eg mockView.Stub(...)) in RhinoMocks 3.5 for AAA style tests. I downloaded the RhinoMocks dll from Ayende's site rather than compiled from source. My project in MonoDevelop is setup to target framework 3....
I am trying to unit test a controller action that uses UpdateModel but I am not correctly mocking the HttpContext. I keep getting the following exception:
System.InvalidOperationException: Previous method 'HttpRequestBase.get_Form();' requires a return value or an exception to throw.
To mock the HttpContext I am using some thing ...
see also "What should I consider when
choosing a mocking framework for
.Net"
I'm trying to decide on a mocking framework to use on a .NET project I've recently embarked on. I'd like to speed my research on the different frameworks. I've recently read this blog post http://codevanced.net/post/Mocking-frameworks-comparison.aspx ...
I am using RhinoMocks, I need to stub a method, and always have it return the third parameter, regardless of what is passed in:
_service.Stub(x => x.Method(parm1, parm2, parm3)).Return(parm3);
Obviously, it ain't that easy. I don't always know what the parms are going to be, but I know I always want to return the 3rd one.
...
I'm looking for some examples on how to do the following Mock Tests using StructureMap or Unity with NUnit.
I have the following code structure
public interface IDAL
{
List<Model> Method1(int id);
}
public class DAL : IDAL
{
public List<Model> Method1(int id)
{
List<Model> retval = new List<Model>();
DbComman...
Hi, I'm trying to mock the Add method of subsonic SimpleRepository with Rihino mocks, I'm using the IRepository Interface but I'm new to mocking and dont know how to go from there, can this be done? thanks for your help.
...
I'm trying to mock a SqlDataReader
SqlDataReader reader = mocks.CreateMock<SqlDataReader>();
Expect.Call(reader.Read()).Return(true).Repeat.Times(1);
Expect.Call(reader.Read()).Return(false);
Expect.Call(reader.HasRows).Return(true);
Expect.Call(reader.Dispose);
Expect.Call(reader["City"]).Return("Boise");
Expect.Call(reader["St...
Hi,
I'm new to mocking, I have a method which takes a lambda as a parameter, how can I mock it using Rhino Mocks? Thanks.
...