blob: 753ee8335133dacf22ca0cb10ca752ae4f7e2db0 (
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
|
using System.Collections.Generic;
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 UpdateRegistrationPresenterTest {
private MockRepository mockery;
private IRegistrationTasks mockTask;
private IUpdateRegistrationView mockView;
private IUpdateRegistrationPresentationMapper mockMapper;
private IHttpRequest mockRequest;
[SetUp]
public void SetUp( ) {
mockery = new MockRepository( );
mockView = mockery.DynamicMock< IUpdateRegistrationView >( );
mockTask = mockery.DynamicMock< IRegistrationTasks >( );
mockMapper = mockery.DynamicMock< IUpdateRegistrationPresentationMapper >( );
mockRequest = mockery.DynamicMock< IHttpRequest >( );
}
[Test]
public void Should_leverage_task_to_load_current_registration_information_for_customer( ) {
int customerId = 1;
using ( mockery.Record( ) ) {
SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.CustomerId ) ).Return( customerId );
Expect.Call( mockTask.LoadRegistrationFor( customerId ) ).Return( null );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).Initialize( );
}
}
[Test]
public void Should_display_the_customer_registration_information_in_the_view( ) {
int customerId = 1;
CustomerRegistrationDisplayDTO customerRegistration = ObjectMother.DisplayCustomerRegistrationDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.CustomerId ) ).Return( customerId );
SetupResult.For( mockTask.LoadRegistrationFor( customerId ) ).Return( customerRegistration );
mockView.Display( customerRegistration );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).Initialize( );
}
}
[Test]
public void Should_leverage_task_to_submit_changed_registration_information( ) {
UpdateCustomerRegistrationDTO customer = ObjectMother.UpdateCustomerRegistrationDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockMapper.MapFrom( mockRequest ) ).Return( customer );
Expect.Call( mockTask.UpdateRegistrationFor( customer ) ).Return( null );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).UpdateRegistration( );
}
}
[Test]
public void Should_display_response_on_view( ) {
IEnumerable< DisplayResponseLineDTO > responseDTO =
ObjectMother.EnumerableDisplayResponseLineDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockTask.UpdateRegistrationFor( null ) ).IgnoreArguments( ).Return( responseDTO );
mockView.Display( responseDTO );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).UpdateRegistration( );
}
}
private IUpdateCustomerRegistrationPresenter CreateSUT( ) {
return new UpdateCustomerRegistrationPresenter( mockView, mockRequest, mockTask, mockMapper );
}
}
}
|