using System.Collections.Generic; 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 InitializeKeyPadCommandTest { [SetUp] public void SetUp() { _mockery = new MockRepository( ); view = _mockery.DynamicMock< ICalculatorView >( ); factory = _mockery.DynamicMock< IAppendDigitCommandFactory >( ); allDigits = new List< IDigit >( Digits.All( ) ); } private IInitializeKeyPadCommand CreateSUT() { return new InitializeKeyPadCommand( view, factory, allDigits ); } [Test] public void should_leverage_task_to_create_a_command_for_each_digit() { using ( _mockery.Record( ) ) { Expect.Call( factory.CreateCommandsFor( allDigits ) ).Return( null ); } using ( _mockery.Playback( ) ) { CreateSUT( ).Execute( ); } } [Test] public void should_bind_commands_to_clickable_controls_on_view() { var commandsToBindTo = new List< IAppendDigitCommand >( ); using ( _mockery.Record( ) ) { SetupResult.For( factory.CreateCommandsFor( null ) ).IgnoreArguments( ).Return( commandsToBindTo ); view.BindToCommands( commandsToBindTo ); } using ( _mockery.Playback( ) ) { CreateSUT( ).Execute( ); } } private MockRepository _mockery; private IList< IDigit > allDigits; private IAppendDigitCommandFactory factory; private ICalculatorView view; } }