blob: 29f9d21183e66b233489f83215b31fa5289a7471 (
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
|
using Marina.Presentation.DTO;
using Marina.Presentation.Mappers;
using Marina.Presentation.Views;
using MbUnit.Framework;
using Rhino.Mocks;
namespace Marina.Test.Unit.Presentation.Mappers {
[TestFixture]
public class CustomerRegistrationPresentationMapperTest {
private MockRepository mockery;
[SetUp]
public void SetUp( ) {
mockery = new MockRepository( );
}
[Test]
public void Should_map_view_data_to_dto( ) {
ICustomerRegistrationView mockView = mockery.DynamicMock< ICustomerRegistrationView >( );
string userName = "mrMO";
string password = "password";
string firstName = "mo";
string lastName = "khan";
string phoneNumber = "(403)6813389";
string city = "calgary";
using ( mockery.Record( ) ) {
SetupResult.For( mockView.UserName( ) ).Return( userName );
SetupResult.For( mockView.Password( ) ).Return( password );
SetupResult.For( mockView.FirstName( ) ).Return( firstName );
SetupResult.For( mockView.LastName( ) ).Return( lastName );
SetupResult.For( mockView.PhoneNumber( ) ).Return( phoneNumber );
SetupResult.For( mockView.City( ) ).Return( city );
}
using ( mockery.Playback( ) ) {
RegisterCustomerDTO mappedDTO = CreateSUT( ).MapFrom( mockView );
Assert.AreEqual( mappedDTO.UserName, userName );
Assert.AreEqual( mappedDTO.Password, password );
Assert.AreEqual( mappedDTO.FirstName, firstName );
Assert.AreEqual( mappedDTO.LastName, lastName );
Assert.AreEqual( mappedDTO.Phone, phoneNumber );
Assert.AreEqual( mappedDTO.City, city );
}
}
private ICustomerRegistrationPresentationMapper CreateSUT( ) {
return new CustomerRegistrationPresentationMapper( );
}
}
}
|