summaryrefslogtreecommitdiff
path: root/slips/src/test/Marina.Test/Integration/DataAccess/Mappers/RegistrationDataMapperTest.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/Integration/DataAccess/Mappers/RegistrationDataMapperTest.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/Integration/DataAccess/Mappers/RegistrationDataMapperTest.cs')
-rw-r--r--slips/src/test/Marina.Test/Integration/DataAccess/Mappers/RegistrationDataMapperTest.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/slips/src/test/Marina.Test/Integration/DataAccess/Mappers/RegistrationDataMapperTest.cs b/slips/src/test/Marina.Test/Integration/DataAccess/Mappers/RegistrationDataMapperTest.cs
new file mode 100644
index 0000000..d4beabf
--- /dev/null
+++ b/slips/src/test/Marina.Test/Integration/DataAccess/Mappers/RegistrationDataMapperTest.cs
@@ -0,0 +1,70 @@
+using Marina.DataAccess;
+using Marina.DataAccess.Builders;
+using Marina.DataAccess.DataMappers;
+using Marina.DataAccess.Schemas;
+using Marina.Domain;
+using Marina.Domain.Interfaces;
+using Marina.Infrastructure.Container;
+using Marina.Test.Utility;
+using MbUnit.Framework;
+
+namespace Marina.Test.Integration.DataAccess.Mappers {
+ [TestFixture]
+ public class RegistrationDataMapperTest {
+ public IRegistrationDataMapper CreateSUT() {
+ return new RegistrationDataMapper( );
+ }
+
+ [RunInRealContainer]
+ [Test]
+ public void Should_be_able_to_find_john() {
+ int customerId = 1000;
+ IRegistration registration = CreateSUT( ).For( customerId );
+ Assert.AreEqual( "John", registration.FirstName( ) );
+ Assert.AreEqual( "Doe", registration.LastName( ) );
+ Assert.AreEqual( "555-545-1212", registration.PhoneNumber( ) );
+ Assert.AreEqual( "Phoenix", registration.City( ) );
+ }
+
+ [RunInRealContainer]
+ [Test]
+ [RollBack]
+ public void Should_be_able_to_insert_new_registration_for_customer() {
+ IRegistrationDataMapper mapper = CreateSUT( );
+ long customerId = CreateCustomerRecord( );
+ IRegistration expectedRegistration =
+ new CustomerRegistration( "mokhan", "password", "mo", "khan", "4036813389", "calgary" );
+
+ mapper.Insert( expectedRegistration, customerId );
+ IRegistration actualRegistration = mapper.For( customerId );
+ Assert.AreEqual( expectedRegistration, actualRegistration );
+ }
+
+ [RunInRealContainer]
+ [Test]
+ [RollBack]
+ public void Should_be_able_to_update_record() {
+ IRegistrationDataMapper mapper = CreateSUT( );
+ long customerId = CreateCustomerRecord( );
+ IRegistration firstRegistration =
+ new CustomerRegistration( "mokhan", "password", "mo", "khan", "4036813389", "calgary" );
+ IRegistration expectedRegistration =
+ new CustomerRegistration( "khanmo", "wordpass", "om", "ankh", "1338940368", "garycal" );
+
+ mapper.Insert( firstRegistration, customerId );
+ mapper.Update( expectedRegistration, customerId );
+
+ IRegistration actualRegistration = mapper.For( customerId );
+ Assert.AreEqual( expectedRegistration, actualRegistration );
+ }
+
+ private long CreateCustomerRecord() {
+ IQuery query = DatabaseInsert.Into( CustomerTable.TableName )
+ .AddValue( CustomerTable.FirstName, string.Empty )
+ .AddValue( CustomerTable.LastName, string.Empty )
+ .AddValue( CustomerTable.Phone, string.Empty )
+ .AddValue( CustomerTable.City, string.Empty ).Build( );
+ return Resolve.DependencyFor< IDatabaseGateway >( ).ExecuteScalar( query );
+ }
+ }
+} \ No newline at end of file