Rhino Mock provides Do()
handler to access stubbed methods arguments at the time when stubbed method is called.
So, it is possible to write a custom handler for Add(MyObj)
method which can store the necessary fields of myObj
argument passed. And then it is possible to run asserts against stored fields.
Here is an example:
string actualMyPropOnAdd = null;
_store
.Stub(s => s.Add(Arg<MyObj>.Is.Anything))
.Do((Action<MyObj>)(myObj =>
{
// save the necessary properties to validate them later
actualMyPropOnAdd = myObj.myProp;
}));
// call CreateAndProcess() here
// validate saved properties:
Assert.That(actualMyPropOnAdd, Is.EqualTo(expectedMyPropOnAdd));
Also I'd recommend to follow one asser per test rule and to write another separate test to validate that argument passed to Update()
method is correct.