using Calculator.Domain; using Calculator.Presentation.Commands; using Calculator.Presentation.Views; using MbUnit.Framework; using Rhino.Mocks; namespace Calculator.Test.presentation.commands { [TestFixture] public class RefreshTotalCommandTest { [SetUp] public void SetUp() { mockery = new MockRepository( ); calculation = mockery.DynamicMock< ICurrentCalculation >( ); view = mockery.DynamicMock< ICalculatorView >( ); } private IRefreshTotalCommand CreateSUT() { return new RefreshTotalCommand( view, calculation ); } [Test] public void should_leverage_calculator_to_compute_the_current_total() { var newTotal = mockery.DynamicMock< INumber >( ); using ( mockery.Record( ) ) { Expect.Call( calculation.IsEqualTo( ) ).Return( newTotal ).Repeat.AtLeastOnce( ); } using ( mockery.Playback( ) ) { CreateSUT( ).Execute( ); } } [Test] public void should_display_the_new_total_on_the_view() { var newTotal = mockery.DynamicMock< INumber >( ); using ( mockery.Record( ) ) { SetupResult.For( calculation.IsEqualTo( ) ).Return( newTotal ).Repeat.AtLeastOnce( ); view.Display( newTotal ); } using ( mockery.Playback( ) ) { CreateSUT( ).Execute( ); } } private ICurrentCalculation calculation; private MockRepository mockery; private ICalculatorView view; } }