blob: e571683cc4f32a6beb13ecd58ab185dcb453d9e6 (
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
|
using System.Collections.Generic;
using Marina.Presentation.DTO;
using Marina.Presentation.Mappers;
using Marina.Presentation.Presenters;
using Marina.Presentation.Views;
using Marina.Task;
using Marina.Test.Utility;
using MbUnit.Framework;
using Rhino.Mocks;
namespace Marina.Test.Unit.Presentation {
[TestFixture]
public class CustomerRegistrationPresenterTest {
private MockRepository mockery;
private ICustomerRegistrationPresentationMapper mockMapper;
private ICustomerRegistrationView mockView;
private IRegistrationTasks mockTask;
[SetUp]
public void SetUp( ) {
mockery = new MockRepository( );
mockMapper = mockery.DynamicMock< ICustomerRegistrationPresentationMapper >( );
mockView = mockery.DynamicMock< ICustomerRegistrationView >( );
mockTask = mockery.DynamicMock< IRegistrationTasks >( );
}
[Test]
public void Should_leverage_mapper_to_convert_view_data_to_dto( ) {
using ( mockery.Record( ) ) {
Expect.Call( mockMapper.MapFrom( mockView ) ).Return( null );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).RegisterCustomer( );
}
}
[Test]
public void Should_leverage_task_to_submit_new_registration_information( ) {
RegisterCustomerDTO customerRegistrationDTO = ObjectMother.CustomerRegistrationDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockMapper.MapFrom( mockView ) ).Return( customerRegistrationDTO );
Expect.Call( mockTask.RegisterNew( customerRegistrationDTO ) ).Return( null );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).RegisterCustomer( );
}
}
[Test]
public void Should_display_response_on_view( ) {
IEnumerable< DisplayResponseLineDTO > responseDTO =
ObjectMother.EnumerableDisplayResponseLineDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockTask.RegisterNew( null ) ).IgnoreArguments( ).Return( responseDTO );
mockView.Display( responseDTO );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).RegisterCustomer( );
}
}
private ICustomerRegistrationPresenter CreateSUT( ) {
return new CustomerRegistrationPresenter( mockView, mockMapper, mockTask );
}
}
}
|