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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
using System;
using System.Collections.Generic;
using Marina.DataAccess.DataMappers;
using Marina.Domain;
using Marina.Domain.Interfaces;
using Marina.Infrastructure;
using Marina.Test.Integration.DataAccess.Utility;
using Marina.Test.Utility;
using MbUnit.Framework;
namespace Marina.Test.Integration.DataAccess.Mappers {
[TestFixture]
public class BoatDataMapperTest {
public IBoatDataMapper CreateSUT() {
return new BoatDataMapper( );
}
[Test]
[RunInRealContainer]
[RollBack]
public void Should_return_3_boats() {
long customerId = CustomerMother.CreateCustomerRecord( );
BoatMother.AddBoatsFor( customerId );
IRichList< IBoat > boats = ListFactory.From( CreateSUT( ).AllBoatsFor( customerId ) );
Assert.AreEqual( 3, boats.Count );
}
[Test]
[RunInRealContainer]
[RollBack]
public void Should_be_able_to_insert_new_boats_for_customer() {
IBoat firstBoat = new Boat( "reg1", "TOYOTA", new DateTime( 2001, 1, 1 ), 100 );
IBoat secondBoat = new Boat( "reg2", "YAMAHA", new DateTime( 2005, 1, 1 ), 200 );
IList< IBoat > boats = new List< IBoat >( );
boats.Add( firstBoat );
boats.Add( secondBoat );
long customerId = CustomerMother.CreateCustomerRecord( );
IBoatDataMapper mapper = CreateSUT( );
mapper.Insert( boats, customerId );
IRichList< IBoat > insertedBoats = ListFactory.From( mapper.AllBoatsFor( customerId ) );
Assert.AreEqual( 2, insertedBoats.Count );
Assert.IsTrue( insertedBoats.Contains( firstBoat ) );
Assert.IsTrue( insertedBoats.Contains( secondBoat ) );
}
[Test]
[RollBack]
[RunInRealContainer]
public void Should_insert_new_boats_for_customer() {
long customerId = CustomerMother.CreateCustomerRecord( );
IList< IBoat > boats = CreateBoats( );
IBoatDataMapper mapper = CreateSUT( );
mapper.Insert( boats, customerId );
IBoat thirdBoat = new Boat( "reg3", "HONDA", new DateTime( 1999, 1, 1 ), 300 );
boats.Add( thirdBoat );
mapper.Update( boats, customerId );
IRichList< IBoat > insertedBoats = ListFactory.From( mapper.AllBoatsFor( customerId ) );
Assert.AreEqual( 3, insertedBoats.Count );
Assert.IsTrue( insertedBoats.Contains( thirdBoat ) );
}
private IList< IBoat > CreateBoats() {
IList< IBoat > boats = new List< IBoat >( );
boats.Add( new Boat( "reg1", "TOYOTA", new DateTime( 2001, 1, 1 ), 100 ) );
boats.Add( new Boat( "reg2", "YAMAHA", new DateTime( 2005, 1, 1 ), 200 ) );
return boats;
}
}
}
|