My test method look like this:
[Test]
public void Generated_CaseNumber_should_be_set_as_LastCaseNumber_in_PropertiesManager()
{
String generatedCaseNumber = _sut.NextCaseNumber();
}
_sut object has a dependency to mocked object of type IPropertiesManager. Method _sut.NextCaseNumber() should generate un...
We are developing our new application in .Net 3.5 and we have started using Rhinomock.
I know it's used for mocking but I don't have good resource for it.
Can anyone suggest me any good resource/link/tutorial for the it?
Thanks in advance...
...
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 want to assert that the save method on my repository was called in two scenarios:
depe...
Hi all,
I am a keen user of RhinoMocks developing from a TDD and AAA perspective with NUnit and ReSharper. I am changing jobs and the team I am moving to uses TypeMock so I want to hit the ground running... and I have run into a problem. How can I get the arguments for a called method on a mock object. When using RhinoMocks I use:
mock...
I am trying to change my unit testing of ArcGIS, and start using mocks (I use rhino).
When I started to get into writing the tests, I noticed I have to start mocking a lot of objects, and stub a lot of methods for even a single test to pass.
For example - my controller first gets a RelationshipClass (so I need to stub the IWorkspace and ...
I have an object under test that makes a fairly complicated call to a data access object. IT looks something like
object.DoSomething(somestring,someObject,someOtherObject,someOtherOtherObject)
In my test structure I have a mocked version of object and I want to test that Dosomething got called with somestring == "value1" and someObjec...
So I have a class with a method as follows:
public class SomeClass
{
...
private SomeDependency m_dependency;
public int DoStuff()
{
int result = 0;
...
int someValue = m_dependency.GrabValue();
...
return result;
}
}
And I've decided that rather than to call m_dependency...
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 method expects an Account object.
This test passes, but it just does not seem correct, becaus...
I'm using RhinoMock in VB.NET and I need to set the return value for a readonly list.
Here's what I want to do (but doesn't work):
dim s = Rhino.Mocks.MockRepository.GenerateStub(of IUserDto)()
s.Id = guid.NewGuid
s.Name = "Stubbed name"
s.Posts = new List(of IPost)
It fails on the compile because Posts is a readonly property.
Then ...
I am trying to write unit tests for a bit of code involving Events. Since I need to raise an event at will, I've decided to rely upon RhinoMocks to do so for me, and then make sure that the results of the events being raised are as expected (when they click a button, values should change in a predictable manner, in this example, the hei...
I have something that looks like the following:
var someList = MockRepository.GenerateStub<IList<ISomething>>();
someList.Add(MockRepository.GenerateStub<ISomething>());
The list gets created as a proxy correctly. However, whenever I try to add an item to the list, it doesn't add the item to the list.
I have a feeling this is becaus...
I have a class TxRx with a property called Common. Common then has a property called LastMod. I want to write a RhinoMock expectation to show that LastMod has been set with something. So I tried:
var txRx = MockRepository.GenerateMock<TxRx>();
var common = MockRepository.GenerateMock<Common>();
txRx.Expect(t => t.Common).Return(comm...
My test is trying to assert that a certain dal method was called, with some parameters.
The method is returning a DataSet object, so my mock just returns an empty DataSet when called.
The problem I have is that when the SUT doesn't call the dal with the proper parameters, the mock will not return the empty DataSet, and so my class will ...
I'm using Rhino Mock 3.5 for .Net Framework 2.0 and when I run this code I get a run time error.
This is the code
IFile fileInterface = MockRepository.GenerateStub<IFile>();<br>
IUrlMapper urlMapper = MockRepository.GenerateStub<IUrlMapper>();
// this is the line causing the run-time error<br>
HttpContextBase mockHttpContext = MockRe...
I am currently refactoring some code which performs Windows Impersonation for testability and have run into a bit of a roadblock. This is the bit of code that I am having trouble with:
...
if (LogonUserA(user, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref token) > 0)
{
if (DuplicateToken(token, 2, ref to...
Is it possible to create a mock object that implements several interfaces with EasyMock?
For example, interface Foo and interface Closeable?
In Rhino Mocks you can provide multiple interfaces when creating a mock object, but EasyMock's createMock() method only takes one type.
Is it possbile to achieve this with EasyMock, without resor...
I'm doing some unit tests for a controller, and I'm mocking the business component. The BC has a public event that I have the controller listening to when the controller is constructed.
The problem I'm having is I keep getting an Expectation error stating:
"IBC.add_MessageRaised(MessageEventHandler) Expected#:1 Actual#:0".
However, I ...
Is there a way to create a mock object based on an already existing object? For example, when unit testing ASP.NET MVC applications, I often run into the problem of mocking repository methods (like GetAll). Usually I want to get this method to return some test data, like this:
private List<Country> CreateCountries()
{
r...
I'm setting up some RhinoMock tests but I can't work out why my expectations are failing.
Here are the class/ interface I'm testing:
public class LogOn {
public virtual ILogOn View { get; set; }
public virtual IDataProvider DataProvider { get; set; }
public void SetUp(ILogOn view) {
this.View = view;
this.DataProvider = ... //u...
Does any know or use and good resources for TTD with ASP.NET MVC specifically with Rhino Mocks.
Do you prefer any other Mocking Framework?
My choice on Rhino Mocks is simply because it seems the one which is most up to date and from what I have read is extremely capable!
...