blob: d5dd99451d87bd2389c1d39fb38dbfa00da7eab6 (
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
|
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 LoginPresenterTest {
private MockRepository mockery;
private ILoginView mockView;
private IAuthenticationTask mockTask;
private ILoginCredentialsMapper mockMapper;
private IHttpRequest mockRequest;
[SetUp]
public void SetUp() {
mockery = new MockRepository( );
mockView = mockery.DynamicMock< ILoginView >( );
mockTask = mockery.DynamicMock< IAuthenticationTask >( );
mockRequest = mockery.DynamicMock< IHttpRequest >( );
mockMapper = mockery.DynamicMock< ILoginCredentialsMapper >( );
}
[Test]
public void Should_leverage_task_to_check_if_credentials_are_correct() {
LoginCredentialsDTO credentials = ObjectMother.LoginCredentialsDTO( );
using ( mockery.Record( ) ) {
SetupResult.For( mockMapper.MapFrom( mockRequest ) ).Return( credentials );
Expect.Call( mockTask.AuthenticateUserUsing( credentials ) ).Return( null );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).Login( );
}
}
[Test]
public void Should_display_response_messages_from_task() {
DisplayResponseLineDTO responseMessage = ObjectMother.DisplayResponseLineDTO( );
using ( mockery.Record( ) ) {
SetupResult
.For( mockTask.AuthenticateUserUsing( null ) )
.IgnoreArguments( )
.Return( responseMessage );
mockView.Display( responseMessage );
}
using ( mockery.Playback( ) ) {
CreateSUT( ).Login( );
}
}
private ILoginPresenter CreateSUT() {
return new LoginPresenter( mockView, mockRequest, mockTask, mockMapper );
}
}
}
|