summaryrefslogtreecommitdiff
path: root/slips/src/test/Marina.Test/Unit/Presentation
diff options
context:
space:
mode:
Diffstat (limited to 'slips/src/test/Marina.Test/Unit/Presentation')
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/AvailableSlipsPresenterTest.cs51
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/CurrentLeasesPresenterTest.cs63
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/CustomerRegistrationPresenterTest.cs69
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/DockPresenterTest.cs90
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/LeaseSlipPresenterTest.cs100
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/LoginPresenterTest.cs62
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/Mappers/CustomerRegistrationPresentationMapperTest.cs52
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/Mappers/LoginCredentialsMapperTest.cs35
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/Mappers/UpdateRegistrationPresentationMapperTest.cs57
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/PayloadKeyTest.cs45
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/RegisterBoatPresenterTest.cs67
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/UpdateRegistrationPresenterTest.cs92
-rw-r--r--slips/src/test/Marina.Test/Unit/Presentation/ViewRegisteredBoatsPresenterTest.cs62
13 files changed, 845 insertions, 0 deletions
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/AvailableSlipsPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/AvailableSlipsPresenterTest.cs
new file mode 100644
index 0000000..5fa950a
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/AvailableSlipsPresenterTest.cs
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+using Marina.Presentation.Presenters;
+using Marina.Presentation.Views;
+using Marina.Task;
+using MbUnit.Framework;
+using Rhino.Mocks;
+
+namespace Marina.Test.Unit.Presentation {
+ [TestFixture]
+ public class AvailableSlipsPresenterTest {
+ private MockRepository mockery;
+ private ICatalogTasks mockTask;
+ private IAvailableSlipsView mockView;
+
+ [SetUp]
+ public void SetUp( ) {
+ mockery = new MockRepository( );
+ mockTask = mockery.DynamicMock< ICatalogTasks >( );
+ mockView = mockery.DynamicMock< IAvailableSlipsView >( );
+ }
+
+ [Test]
+ public void Should_leverage_task_to_retrieve_all_available_slips_on_initialize( ) {
+ using ( mockery.Record( ) ) {
+ Expect.Call( mockTask.GetAllAvailableSlips( ) ).Return( null );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_display_the_available_slips( ) {
+ IEnumerable< SlipDisplayDTO > availableSlips = new List< SlipDisplayDTO >( );
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockTask.GetAllAvailableSlips( ) ).Return( availableSlips );
+ mockView.Display( availableSlips );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ private IAvailableSlipsPresenter CreateSUT( ) {
+ return new AvailableSlipsPresenter( mockView, mockTask );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/CurrentLeasesPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/CurrentLeasesPresenterTest.cs
new file mode 100644
index 0000000..a9f2cb1
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/CurrentLeasesPresenterTest.cs
@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+using Marina.Presentation;
+using Marina.Presentation.DTO;
+using Marina.Presentation.Presenters;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+using MbUnit.Framework;
+using Rhino.Mocks;
+
+namespace Marina.Test.Unit.Presentation {
+ [TestFixture]
+ public class CurrentLeasesPresenterTest {
+ private MockRepository _mockery;
+ private ILeaseTasks task;
+ private IHttpRequest mockRequest;
+ private ICurrentLeasesView mockView;
+
+ [SetUp]
+ public void Setup() {
+ _mockery = new MockRepository( );
+ task = _mockery.DynamicMock< ILeaseTasks >( );
+ mockRequest = _mockery.DynamicMock< IHttpRequest >( );
+ mockView = _mockery.DynamicMock< ICurrentLeasesView >( );
+ }
+
+ public ICurrentLeasesPresenter CreateSUT() {
+ return new CurrentLeasesPresenter( mockView, mockRequest, task );
+ }
+
+ [Test]
+ public void Should_leverage_task_to_retrieve_all_leases_for_customer_id() {
+ long customerId = 32;
+ IList< DisplayLeaseDTO > dtos = new List< DisplayLeaseDTO >( );
+
+ using ( _mockery.Record( ) ) {
+ SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.CustomerId ) ).Return( customerId );
+ Expect.Call( task.FindAllLeasesFor( customerId ) ).Return( dtos );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_display_the_found_leases_on_the_view() {
+ IList< DisplayLeaseDTO > dtos = new List< DisplayLeaseDTO >( );
+ using ( _mockery.Record( ) ) {
+ SetupResult
+ .For( task.FindAllLeasesFor( 0 ) )
+ .IgnoreArguments( )
+ .Return( dtos );
+
+ mockView.Display( dtos );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/CustomerRegistrationPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/CustomerRegistrationPresenterTest.cs
new file mode 100644
index 0000000..e571683
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/CustomerRegistrationPresenterTest.cs
@@ -0,0 +1,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 );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/DockPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/DockPresenterTest.cs
new file mode 100644
index 0000000..1fc2a26
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/DockPresenterTest.cs
@@ -0,0 +1,90 @@
+using System.Collections.Generic;
+using Marina.Presentation;
+using Marina.Presentation.DTO;
+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 DockPresenterTest {
+ private MockRepository mockery;
+ private IDockView mockView;
+ private ICatalogTasks mockTask;
+ private IHttpRequest mockRequest;
+
+ private IDockPresenter CreateSUT( ) {
+ return new DockPresenter( mockView, mockRequest, mockTask );
+ }
+
+ [SetUp]
+ public void SetUp( ) {
+ mockery = new MockRepository( );
+ mockView = mockery.DynamicMock< IDockView >( );
+ mockTask = mockery.DynamicMock< ICatalogTasks >( );
+ mockRequest = mockery.DynamicMock< IHttpRequest >( );
+ }
+
+ [Test]
+ public void Should_leverage_its_task_to_retrieve_the_dock_information( ) {
+ long dockId = 1;
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.DockId ) ).Return( dockId );
+ Expect.Call( mockTask.GetDockInformationBy( dockId ) ).Return( null );
+ }
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_display_dock_information( ) {
+ DockDisplayDTO dto = ObjectMother.DockDisplayDTO( );
+ int dockId = 2;
+
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.DockId ) ).Return( dockId );
+ SetupResult.For( mockTask.GetDockInformationBy( dockId ) ).Return( dto );
+ mockView.Display( dto );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_leverage_task_to__load_list_of_locations_on_initialize( ) {
+ long dockId = 1;
+
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.DockId ) ).Return( dockId );
+ Expect.Call( mockTask.GetAvailableSlipsForDockBy( dockId ) ).Return( null );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_display_the_available_slips( ) {
+ IEnumerable< SlipDisplayDTO > availableSlips = new List< SlipDisplayDTO >( );
+ long dockId = 2;
+
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.DockId ) ).Return( dockId );
+ SetupResult.For( mockTask.GetAvailableSlipsForDockBy( dockId ) ).Return( availableSlips );
+ mockView.Display( availableSlips );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/LeaseSlipPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/LeaseSlipPresenterTest.cs
new file mode 100644
index 0000000..d53f9f9
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/LeaseSlipPresenterTest.cs
@@ -0,0 +1,100 @@
+using Marina.Presentation;
+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 LeaseSlipPresenterTest {
+ private MockRepository _mockery;
+ private IHttpRequest _mockRequest;
+ private ICatalogTasks _mockTask;
+ private ILeaseSlipView _mockView;
+ private ILeaseTasks _mockLeaseTasks;
+ private ILeaseRequestDtoFromHttpRequestMapper _mockMapper;
+
+ [SetUp]
+ public void Setup() {
+ _mockery = new MockRepository( );
+ _mockRequest = _mockery.DynamicMock< IHttpRequest >( );
+ _mockTask = _mockery.DynamicMock< ICatalogTasks >( );
+ _mockLeaseTasks = _mockery.DynamicMock< ILeaseTasks >( );
+ _mockView = _mockery.DynamicMock< ILeaseSlipView >( );
+
+ _mockMapper = _mockery.DynamicMock< ILeaseRequestDtoFromHttpRequestMapper >( );
+ }
+
+ public ILeaseSlipPresenter CreateSUT() {
+ return new LeaseSlipPresenter( _mockView, _mockRequest, _mockTask, _mockLeaseTasks, _mockMapper );
+ }
+
+ [Test]
+ public void Should_leverage_task_to_retrieve_information_on_slip() {
+ long slipId = 66;
+ SlipDisplayDTO slip = ObjectMother.SlipDisplayDTO( );
+ using ( _mockery.Record( ) ) {
+ SetupResult.For( _mockRequest.ParsePayloadFor( PayloadKeys.SlipId ) ).Return( slipId );
+ Expect.Call( _mockTask.FindSlipBy( slipId ) ).Return( slip );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_display_found_slip_on_view() {
+ SlipDisplayDTO slip = ObjectMother.SlipDisplayDTO( );
+ using ( _mockery.Record( ) ) {
+ SetupResult.For( _mockTask.FindSlipBy( 0 ) ).IgnoreArguments( ).Return( slip );
+ _mockView.Display( slip );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_save_lease_slip_when_customer_submits_a_request() {
+ long customerId = 2;
+ long slipId = 3;
+
+ SubmitLeaseRequestDTO request = new SubmitLeaseRequestDTO( customerId, slipId, "weekly" );
+ DisplayResponseLineDTO response = new DisplayResponseLineDTO( "" );
+
+ using ( _mockery.Record( ) ) {
+ SetupResult.For( _mockMapper.MapFrom( _mockRequest ) ).Return( request );
+ Expect.Call( _mockLeaseTasks.RequestLeaseUsing( request ) ).Return( response );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).SubmitLeaseRequest( );
+ }
+ }
+
+ [Test]
+ public void Should_display_response_from_lease_request_on_the_view() {
+ SubmitLeaseRequestDTO request = new SubmitLeaseRequestDTO( 1, 1, "weekly" );
+ DisplayResponseLineDTO response = new DisplayResponseLineDTO( "" );
+
+ using ( _mockery.Record( ) ) {
+ SetupResult
+ .For( _mockLeaseTasks.RequestLeaseUsing( request ) )
+ .IgnoreArguments( )
+ .Return( response );
+ _mockView.Display( response );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).SubmitLeaseRequest( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/LoginPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/LoginPresenterTest.cs
new file mode 100644
index 0000000..d5dd994
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/LoginPresenterTest.cs
@@ -0,0 +1,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 );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/Mappers/CustomerRegistrationPresentationMapperTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/Mappers/CustomerRegistrationPresentationMapperTest.cs
new file mode 100644
index 0000000..29f9d21
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/Mappers/CustomerRegistrationPresentationMapperTest.cs
@@ -0,0 +1,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( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/Mappers/LoginCredentialsMapperTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/Mappers/LoginCredentialsMapperTest.cs
new file mode 100644
index 0000000..4dae259
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/Mappers/LoginCredentialsMapperTest.cs
@@ -0,0 +1,35 @@
+using Marina.Presentation;
+using Marina.Presentation.Mappers;
+using Marina.Web;
+using MbUnit.Framework;
+using Rhino.Mocks;
+
+namespace Marina.Test.Unit.Presentation.Mappers {
+ [TestFixture]
+ public class LoginCredentialsMapperTest {
+ private MockRepository mockery;
+ private IHttpRequest mockRequest;
+
+ [SetUp]
+ public void SetUp( ) {
+ mockery = new MockRepository( );
+ mockRequest = mockery.DynamicMock< IHttpRequest >( );
+ }
+
+ [Test]
+ public void Should_map_username_from_request( ) {
+ using ( mockery.Record( ) ) {
+ Expect.Call( mockRequest.ParsePayloadFor( PayloadKeys.For( "uxUserNameTextBox" ) ) ).Return( null );
+ Expect.Call( mockRequest.ParsePayloadFor( PayloadKeys.For( "uxPasswordTextBox" ) ) ).Return( null );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).MapFrom( mockRequest );
+ }
+ }
+
+ private LoginCredentialsMapper CreateSUT( ) {
+ return new LoginCredentialsMapper( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/Mappers/UpdateRegistrationPresentationMapperTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/Mappers/UpdateRegistrationPresentationMapperTest.cs
new file mode 100644
index 0000000..510756f
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/Mappers/UpdateRegistrationPresentationMapperTest.cs
@@ -0,0 +1,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( );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/PayloadKeyTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/PayloadKeyTest.cs
new file mode 100644
index 0000000..b7a3540
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/PayloadKeyTest.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Specialized;
+using Marina.Presentation;
+using MbUnit.Framework;
+
+namespace Marina.Test.Unit.Presentation {
+ [TestFixture]
+ public class PayloadKeyTest {
+ [Test]
+ public void Should_be_able_to_convert_an_item_from_the_payload_into_an_item_of_the_correct_type( ) {
+ string key = "DID";
+ int expectedValue = 1;
+
+ NameValueCollection payload = new NameValueCollection( );
+ payload.Add( key, expectedValue.ToString( ) );
+
+ int actualValue = CreateSUT< int >( key ).ParseFrom( payload );
+ Assert.AreEqual( expectedValue, actualValue );
+ }
+
+ [Test]
+ [ExpectedException( typeof( Exception ) )]
+ public void Should_not_be_able_to_parse_if_the_item_in_the_payload_does_not_match_the_data_type_for_the_key( ) {
+ NameValueCollection payload = new NameValueCollection( );
+ payload.Add( "DID", "NotAnInt" );
+ CreateSUT< int >( "DID" ).ParseFrom( payload );
+ }
+
+ [Test]
+ public void Should_be_able_to_implicitly_cast_to_a_string( ) {
+ string implictlyCasted = CreateSUT< int >( "DID" );
+ Assert.AreEqual( "DID", implictlyCasted );
+ }
+
+ [Test]
+ [ExpectedException( typeof( PayloadKeyNotFoundException ) )]
+ public void Should_return_default_value_if_key_is_not_in_payload( ) {
+ CreateSUT< string >( "NOTINPAYLOAD" ).ParseFrom( new NameValueCollection( ) );
+ }
+
+ private PayloadKey< T > CreateSUT< T >( string key ) {
+ return new PayloadKey< T >( key );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/RegisterBoatPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/RegisterBoatPresenterTest.cs
new file mode 100644
index 0000000..2daf6f2
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/RegisterBoatPresenterTest.cs
@@ -0,0 +1,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 );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/UpdateRegistrationPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/UpdateRegistrationPresenterTest.cs
new file mode 100644
index 0000000..753ee83
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/UpdateRegistrationPresenterTest.cs
@@ -0,0 +1,92 @@
+using System.Collections.Generic;
+using Marina.Presentation;
+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 UpdateRegistrationPresenterTest {
+ private MockRepository mockery;
+ private IRegistrationTasks mockTask;
+ private IUpdateRegistrationView mockView;
+ private IUpdateRegistrationPresentationMapper mockMapper;
+ private IHttpRequest mockRequest;
+
+ [SetUp]
+ public void SetUp( ) {
+ mockery = new MockRepository( );
+ mockView = mockery.DynamicMock< IUpdateRegistrationView >( );
+ mockTask = mockery.DynamicMock< IRegistrationTasks >( );
+ mockMapper = mockery.DynamicMock< IUpdateRegistrationPresentationMapper >( );
+ mockRequest = mockery.DynamicMock< IHttpRequest >( );
+ }
+
+ [Test]
+ public void Should_leverage_task_to_load_current_registration_information_for_customer( ) {
+ int customerId = 1;
+
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.CustomerId ) ).Return( customerId );
+ Expect.Call( mockTask.LoadRegistrationFor( customerId ) ).Return( null );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_display_the_customer_registration_information_in_the_view( ) {
+ int customerId = 1;
+ CustomerRegistrationDisplayDTO customerRegistration = ObjectMother.DisplayCustomerRegistrationDTO( );
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockRequest.ParsePayloadFor( PayloadKeys.CustomerId ) ).Return( customerId );
+ SetupResult.For( mockTask.LoadRegistrationFor( customerId ) ).Return( customerRegistration );
+ mockView.Display( customerRegistration );
+ }
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_leverage_task_to_submit_changed_registration_information( ) {
+ UpdateCustomerRegistrationDTO customer = ObjectMother.UpdateCustomerRegistrationDTO( );
+
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockMapper.MapFrom( mockRequest ) ).Return( customer );
+ Expect.Call( mockTask.UpdateRegistrationFor( customer ) ).Return( null );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).UpdateRegistration( );
+ }
+ }
+
+ [Test]
+ public void Should_display_response_on_view( ) {
+ IEnumerable< DisplayResponseLineDTO > responseDTO =
+ ObjectMother.EnumerableDisplayResponseLineDTO( );
+
+ using ( mockery.Record( ) ) {
+ SetupResult.For( mockTask.UpdateRegistrationFor( null ) ).IgnoreArguments( ).Return( responseDTO );
+ mockView.Display( responseDTO );
+ }
+
+ using ( mockery.Playback( ) ) {
+ CreateSUT( ).UpdateRegistration( );
+ }
+ }
+
+ private IUpdateCustomerRegistrationPresenter CreateSUT( ) {
+ return new UpdateCustomerRegistrationPresenter( mockView, mockRequest, mockTask, mockMapper );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Presentation/ViewRegisteredBoatsPresenterTest.cs b/slips/src/test/Marina.Test/Unit/Presentation/ViewRegisteredBoatsPresenterTest.cs
new file mode 100644
index 0000000..1443153
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Presentation/ViewRegisteredBoatsPresenterTest.cs
@@ -0,0 +1,62 @@
+using System.Collections.Generic;
+using Marina.Presentation;
+using Marina.Presentation.DTO;
+using Marina.Presentation.Presenters;
+using Marina.Presentation.Views;
+using Marina.Task;
+using Marina.Web;
+using MbUnit.Framework;
+using Rhino.Mocks;
+
+namespace Marina.Test.Unit.Presentation {
+ [TestFixture]
+ public class ViewRegisteredBoatsPresenterTest {
+ private MockRepository _mockery;
+ private IRegistrationTasks _mockTask;
+ private IHttpRequest _mockRequest;
+ private IRegisteredBoatsView _mockView;
+
+ [SetUp]
+ public void Setup() {
+ _mockery = new MockRepository( );
+ _mockTask = _mockery.DynamicMock< IRegistrationTasks >( );
+ _mockRequest = _mockery.DynamicMock< IHttpRequest >( );
+ _mockView = _mockery.DynamicMock< IRegisteredBoatsView >( );
+ }
+
+ public IViewRegisteredBoatsPresenter CreateSUT() {
+ return new ViewRegisteredBoatsPresenter( _mockView, _mockTask, _mockRequest );
+ }
+
+ [Test]
+ public void Should_leverage_task_to_retrieve_all_registered_boats_for_customer() {
+ long customerId = 23;
+ IList< BoatRegistrationDTO > boats = new List< BoatRegistrationDTO >( );
+
+ using ( _mockery.Record( ) ) {
+ SetupResult.For( _mockRequest.ParsePayloadFor( PayloadKeys.CustomerId ) ).Return( customerId );
+ Expect.Call( _mockTask.AllBoatsFor( customerId ) ).Return( boats );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+
+ [Test]
+ public void Should_display_registered_boats_on_view() {
+ IList< BoatRegistrationDTO > boats = new List< BoatRegistrationDTO >( );
+ using ( _mockery.Record( ) ) {
+ SetupResult.For( _mockTask.AllBoatsFor( 0 ) )
+ .IgnoreArguments( )
+ .Return( boats );
+
+ _mockView.Display( boats );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Initialize( );
+ }
+ }
+ }
+} \ No newline at end of file