blob: d53f9f9c6741b206aec109bd1192fca7f7b14d9c (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
using Marina.Presentation;
using Marina.Presentation.DTO;
using Marina.Presentation.Mappers;
using Marina.Presentation.Presenters;
using Marina.Presentation.Views;
using Marina.Task;
using Marina.Test.Utility;
using Marina.Web;
using MbUnit.Framework;
using Rhino.Mocks;
namespace Marina.Test.Unit.Presentation {
[TestFixture]
public class LeaseSlipPresenterTest {
private MockRepository _mockery;
private IHttpRequest _mockRequest;
private ICatalogTasks _mockTask;
private ILeaseSlipView _mockView;
private ILeaseTasks _mockLeaseTasks;
private ILeaseRequestDtoFromHttpRequestMapper _mockMapper;
[SetUp]
public void Setup() {
_mockery = new MockRepository( );
_mockRequest = _mockery.DynamicMock< IHttpRequest >( );
_mockTask = _mockery.DynamicMock< ICatalogTasks >( );
_mockLeaseTasks = _mockery.DynamicMock< ILeaseTasks >( );
_mockView = _mockery.DynamicMock< ILeaseSlipView >( );
_mockMapper = _mockery.DynamicMock< ILeaseRequestDtoFromHttpRequestMapper >( );
}
public ILeaseSlipPresenter CreateSUT() {
return new LeaseSlipPresenter( _mockView, _mockRequest, _mockTask, _mockLeaseTasks, _mockMapper );
}
[Test]
public void Should_leverage_task_to_retrieve_information_on_slip() {
long slipId = 66;
SlipDisplayDTO slip = ObjectMother.SlipDisplayDTO( );
using ( _mockery.Record( ) ) {
SetupResult.For( _mockRequest.ParsePayloadFor( PayloadKeys.SlipId ) ).Return( slipId );
Expect.Call( _mockTask.FindSlipBy( slipId ) ).Return( slip );
}
using ( _mockery.Playback( ) ) {
CreateSUT( ).Initialize( );
}
}
[Test]
public void Should_display_found_slip_on_view() {
SlipDisplayDTO slip = ObjectMother.SlipDisplayDTO( );
using ( _mockery.Record( ) ) {
SetupResult.For( _mockTask.FindSlipBy( 0 ) ).IgnoreArguments( ).Return( slip );
_mockView.Display( slip );
}
using ( _mockery.Playback( ) ) {
CreateSUT( ).Initialize( );
}
}
[Test]
public void Should_save_lease_slip_when_customer_submits_a_request() {
long customerId = 2;
long slipId = 3;
SubmitLeaseRequestDTO request = new SubmitLeaseRequestDTO( customerId, slipId, "weekly" );
DisplayResponseLineDTO response = new DisplayResponseLineDTO( "" );
using ( _mockery.Record( ) ) {
SetupResult.For( _mockMapper.MapFrom( _mockRequest ) ).Return( request );
Expect.Call( _mockLeaseTasks.RequestLeaseUsing( request ) ).Return( response );
}
using ( _mockery.Playback( ) ) {
CreateSUT( ).SubmitLeaseRequest( );
}
}
[Test]
public void Should_display_response_from_lease_request_on_the_view() {
SubmitLeaseRequestDTO request = new SubmitLeaseRequestDTO( 1, 1, "weekly" );
DisplayResponseLineDTO response = new DisplayResponseLineDTO( "" );
using ( _mockery.Record( ) ) {
SetupResult
.For( _mockLeaseTasks.RequestLeaseUsing( request ) )
.IgnoreArguments( )
.Return( response );
_mockView.Display( response );
}
using ( _mockery.Playback( ) ) {
CreateSUT( ).SubmitLeaseRequest( );
}
}
}
}
|