blob: 2daf6f21b1760e67802019101ae935f79fc11c84 (
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
|
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 Marina.Web;
using MbUnit.Framework;
using Rhino.Mocks;
namespace Marina.Test.Unit.Presentation {
[TestFixture]
public class RegisterBoatPresenterTest {
private MockRepository mockery;
private IRegisterBoatView mockView;
private IRegistrationTasks mockTask;
private IHttpRequest mockRequest;
private INewBoatRegistrationMapper mockMapper;
[SetUp]
public void SetUp() {
mockery = new MockRepository( );
mockView = mockery.DynamicMock< IRegisterBoatView >( );
mockTask = mockery.DynamicMock< IRegistrationTasks >( );
mockRequest = mockery.DynamicMock< IHttpRequest >( );
mockMapper = mockery.DynamicMock< INewBoatRegistrationMapper >( );
}
[Test]
public void Should_leverage_task_to_submit_new_boat_registration() {
IEnumerable< DisplayResponseLineDTO > response = ObjectMother.EnumerableDisplayResponseLineDTO( );
BoatRegistrationDTO boat = ObjectMother.BoatRegistrationDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockMapper.MapFrom( mockRequest ) ).Return( boat );
Expect.Call( mockTask.AddNewBoatUsing( boat ) ).Return( response );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).SubmitRegistration( );
}
}
[Test]
public void Should_display_response_from_task_on_view() {
IEnumerable< DisplayResponseLineDTO > response = ObjectMother.EnumerableDisplayResponseLineDTO( );
BoatRegistrationDTO boat = ObjectMother.BoatRegistrationDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockMapper.MapFrom( mockRequest ) ).Return( boat );
SetupResult.For( mockTask.AddNewBoatUsing( boat ) ).Return( response );
mockView.Display( response );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).SubmitRegistration( );
}
}
private IRegisterBoatPresenter CreateSUT() {
return new RegisterBoatPresenter( mockView, mockRequest, mockTask, mockMapper );
}
}
}
|