Returning a complex data type from arguments with Rhino Mocks
Posted
by Joseph
on Stack Overflow
See other posts from Stack Overflow
or by Joseph
Published on 2010-04-09T17:25:15Z
Indexed on
2010/04/10
11:23 UTC
Read the original article
Hit count: 330
rhino-mocks
|unit-testing
I'm trying to set up a stub with Rhino Mocks which returns a value based on what the parameter of the argument that is passed in.
Example:
//Arrange
var car = new Car();
var provider= MockRepository.GenerateStub<IDataProvider>();
provider.Stub(
x => x.GetWheelsWithSize(Arg<int>.Is.Anything))
.Return(new List<IWheel> {
new Wheel { Size = ?, Make = Make.Michelin },
new Wheel { Size = ?, Make = Make.Firestone }
});
car.Provider = provider;
//Act
car.ReplaceTires();
//Assert that the right tire size was used when replacing the tires
The problem is that I want Size to be whatever was passed into the method, because I'm actually asserting later that the wheels are the right size. This is not to prove that the data provider works obviously since I stubbed it, but rather to prove that the correct size was passed in.
How can I do this?
© Stack Overflow or respective owner