summaryrefslogtreecommitdiff
path: root/slips/src/test/Marina.Test/Unit/DataAccess/Mappers/CustomerDataMapperTest.cs
diff options
context:
space:
mode:
authormokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219>2009-02-21 21:44:27 +0000
committermokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219>2009-02-21 21:44:27 +0000
commit1dfdccb8118aeaa3cd844ac8de2a672c93312166 (patch)
tree4b19e7f816ab1019f180a46b68572af4b66fe4bc /slips/src/test/Marina.Test/Unit/DataAccess/Mappers/CustomerDataMapperTest.cs
parent42d66bcab8262c7b8b2452615df535e694a3ec1c (diff)
git-svn-id: http://svn.xp-dev.com/svn/mokhan-sait@2 da190166-9cfc-4ee1-ae03-434a172be219
Diffstat (limited to 'slips/src/test/Marina.Test/Unit/DataAccess/Mappers/CustomerDataMapperTest.cs')
-rw-r--r--slips/src/test/Marina.Test/Unit/DataAccess/Mappers/CustomerDataMapperTest.cs86
1 files changed, 86 insertions, 0 deletions
diff --git a/slips/src/test/Marina.Test/Unit/DataAccess/Mappers/CustomerDataMapperTest.cs b/slips/src/test/Marina.Test/Unit/DataAccess/Mappers/CustomerDataMapperTest.cs
new file mode 100644
index 0000000..81e170b
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/DataAccess/Mappers/CustomerDataMapperTest.cs
@@ -0,0 +1,86 @@
+using System.Collections.Generic;
+using Marina.DataAccess;
+using Marina.DataAccess.DataMappers;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure;
+using MbUnit.Framework;
+using Rhino.Mocks;
+
+namespace Marina.Test.Unit.DataAccess.Mappers {
+ [TestFixture]
+ public class CustomerDataMapperTest {
+ private MockRepository _mockery;
+ private IDatabaseGateway _mockGateway;
+ private IBoatDataMapper _boatMapper;
+ private ILeaseDataMapper _leaseDataMapper;
+ private IRegistrationDataMapper _registrationMapper;
+
+ [SetUp]
+ public void Setup() {
+ _mockery = new MockRepository( );
+ _mockGateway = _mockery.DynamicMock< IDatabaseGateway >( );
+ _boatMapper = _mockery.DynamicMock< IBoatDataMapper >( );
+ _leaseDataMapper = _mockery.DynamicMock< ILeaseDataMapper >( );
+ _registrationMapper = _mockery.DynamicMock< IRegistrationDataMapper >( );
+ }
+
+ public ICustomerDataMapper CreateSUT() {
+ return new CustomerDataMapper( _mockGateway, _boatMapper, _leaseDataMapper, _registrationMapper );
+ }
+
+ [Test]
+ public void Should_leverage_mapper_to_load_customers_boats() {
+ long customerId = 32;
+
+ IList< IBoat > boats = new List< IBoat >( );
+ IBoat boat = _mockery.DynamicMock< IBoat >( );
+ boats.Add( boat );
+
+ using ( _mockery.Record( ) ) {
+ Expect.Call( _boatMapper.AllBoatsFor( customerId ) ).Return( boats );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ ICustomer customer = CreateSUT( ).FindBy( customerId );
+ Assert.AreEqual( 1, ListFactory.From( customer.RegisteredBoats( ) ).Count );
+ Assert.IsTrue( ListFactory.From( customer.RegisteredBoats( ) ).Contains( boat ) );
+ }
+ }
+
+ [Test]
+ public void Should_leverage_mapper_to_load_customer_leases() {
+ long customerId = 32;
+ IList< ISlipLease > leases = new List< ISlipLease >( );
+ ISlipLease lease = _mockery.DynamicMock< ISlipLease >( );
+ leases.Add( lease );
+
+ using ( _mockery.Record( ) ) {
+ Expect
+ .Call( _leaseDataMapper.AllLeasesFor( customerId ) )
+ .Return( leases );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ ICustomer customer = CreateSUT( ).FindBy( customerId );
+ Assert.AreEqual( 1, ListFactory.From( customer.Leases( ) ).Count );
+ Assert.IsTrue( ListFactory.From( customer.Leases( ) ).Contains( lease ) );
+ }
+ }
+
+ [Test]
+ public void Should_leverage_mapper_to_load_customer_registration() {
+ long customerId = 59;
+
+ IRegistration registration = _mockery.DynamicMock< IRegistration >( );
+
+ using ( _mockery.Record( ) ) {
+ Expect.Call( _registrationMapper.For( customerId ) ).Return( registration );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ ICustomer customer = CreateSUT( ).FindBy( customerId );
+ Assert.AreEqual( registration, customer.Registration( ) );
+ }
+ }
+ }
+} \ No newline at end of file