I'm using Rhino Mocks 3.5 to mock a service method call which takes 2 parameters and I want to make sure a propery on an object is being set correctly.
// Method being tested
void UpdateDelivery( Trade trade )
{
trade.Delivery = new DateTime( 2013, 7, 4 );
m_Service.UpdateTrade( trade, m_Token ); // mocking this
}
Here's a portion of my code (which works)
service, trade, token declared / new'd up ... etc.
...
using ( m_Mocks.Record() )
{
Action<Trade, Token> onCalled = ( tradeParam, tokenParam ) =>
{
// Inspect / verify that Delivery prop is set correctly
// when UpdateTrade called
Assert.AreEqual( new DateTime( 2013, 7, 4 ), tradeParam.Delivery );
};
Expect.Call( () => m_Service.UpdateTrade( Arg<Trade>.Is.Equal( trade ), Arg<Token>.Is.Equal( token ) ) ).Do( onCalled );
}
using ( m_Mocks.Playback() )
{
m_Adjuster = new Adjuster( service, token );
m_Adjuster.UpdateDelivery( trade );
}
Is there a better, more concise, straightfoward way to test this using Rhino Mocks? I've seen posts where Contraints are used but I'm not a fan of identifying properties / value by string names.