blob: f55bd373ff92d328ba443ab06eaaceb623c4b4c0 (
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
53
54
55
56
57
58
59
60
61
62
63
64
|
using Calculator.Domain;
using Calculator.Presentation.Commands;
using MbUnit.Framework;
using Rhino.Mocks;
namespace Calculator.Test.presentation.commands {
[TestFixture]
public class AdditionOperationCommandTest {
[SetUp]
public void SetUp() {
mockery = new MockRepository( );
builder = mockery.DynamicMock< INumberBuilder >( );
calculation = mockery.DynamicMock< ICurrentCalculation >( );
}
private IAdditionOperationCommand CreateSUT() {
return new AdditionOperationCommand( builder, calculation );
}
[Test]
public void should_leverage_builder_to_retrieve_the_current_number() {
using ( mockery.Record( ) ) {
Expect.Call( builder.Build( ) ).Return( null ).Repeat.AtLeastOnce( );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).Execute( );
}
}
[Test]
public void Should_start_new_expression_using_the_number_retrieved_from_the_builder() {
var number = mockery.DynamicMock< INumber >( );
using ( mockery.Record( ) ) {
SetupResult.For( builder.Build( ) ).Return( number );
calculation.Enter( number );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).Execute( );
}
}
[Test]
public void should_append_addition_operation_to_calculation() {
using ( mockery.Record( ) ) {
using ( mockery.Ordered( ) ) {
calculation.Enter( null );
LastCall.IgnoreArguments( );
calculation.Include( Operators.Addition );
}
}
using ( mockery.Playback( ) ) {
CreateSUT( ).Execute( );
}
}
private INumberBuilder builder;
private ICurrentCalculation calculation;
private MockRepository mockery;
}
}
|