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
|
using Marina.Presentation;
using Marina.Presentation.DTO;
using Marina.Presentation.Mappers;
using Marina.Web;
using MbUnit.Framework;
using Rhino.Mocks;
namespace Marina.Test.Unit.Presentation.Mappers {
[TestFixture]
public class UpdateRegistrationPresentationMapperTest {
private MockRepository mockery;
private IHttpRequest mockRequest;
[SetUp]
public void SetUp( ) {
mockery = new MockRepository( );
mockRequest = mockery.DynamicMock< IHttpRequest >( );
}
[RowTest]
[Row( 0, "username", "password", "mo", "khan", "4036813389", "calgary" )]
[Row( 0, "username1", "p@ssword", "m0", "khAAn", "d33d9", "toronto" )]
[Row( 0, "username2", "passw0rd", "m1", "kh@n", "4036d333389", "new york" )]
public void Should_map_the_data_from_the_view_to_the_dto( long customerId, string userName, string password,
string firstName,
string lastName, string phone, string city ) {
using ( mockery.Record( ) ) {
SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.CustomerId ) ).Return( customerId );
SetupResult.For( mockRequest.ParsePayloadFor( Create( "uxUserNameTextBox" ) ) ).Return( userName );
SetupResult.For( mockRequest.ParsePayloadFor( Create( "uxPasswordTextBox" ) ) ).Return( password );
SetupResult.For( mockRequest.ParsePayloadFor( Create( "uxFirstNameTextBox" ) ) ).Return( firstName );
SetupResult.For( mockRequest.ParsePayloadFor( Create( "uxLastNameTextBox" ) ) ).Return( lastName );
SetupResult.For( mockRequest.ParsePayloadFor( Create( "uxPhoneNumberTextBox" ) ) ).Return( phone );
SetupResult.For( mockRequest.ParsePayloadFor( Create( "uxCityTextBox" ) ) ).Return( city );
}
using ( mockery.Playback( ) ) {
UpdateCustomerRegistrationDTO dto = CreateSUT( ).MapFrom( mockRequest );
Assert.AreEqual( customerId, dto.CustomerId );
Assert.AreEqual( userName, dto.Username );
Assert.AreEqual( password, dto.Password );
Assert.AreEqual( firstName, dto.FirstName );
Assert.AreEqual( lastName, dto.LastName );
Assert.AreEqual( phone, dto.PhoneNumber );
Assert.AreEqual( city, dto.City );
}
}
public PayloadKey< string > Create( string controlId ) {
return PayloadKeys.For( controlId );
}
private IUpdateRegistrationPresentationMapper CreateSUT( ) {
return new UpdateRegistrationPresentationMapper( );
}
}
}
|