blob: 704b5e0dc7456787fb9a9734a407509b42583680 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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;
}
}
|