summaryrefslogtreecommitdiff
path: root/slips/src/test/Marina.Test/Integration/DataAccess/Utility/CustomerMother.cs
blob: 923528ae6eefbef7f3d34b909c222a33471a7c39 (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
using Marina.DataAccess;
using Marina.DataAccess.Builders;
using Marina.DataAccess.Schemas;
using Marina.Infrastructure.Container;

namespace Marina.Test.Integration.DataAccess.Utility {
	public static class CustomerMother {
		public static long CreateCustomerRecord() {
			IInsertQueryBuilder builder = DatabaseInsert.Into( CustomerTable.TableName )
				.AddValue( CustomerTable.FirstName, string.Empty )
				.AddValue( CustomerTable.LastName, string.Empty )
				.AddValue( CustomerTable.Phone, string.Empty )
				.AddValue( CustomerTable.City, string.Empty );
			return Resolve.DependencyFor< IDatabaseGateway >( ).ExecuteScalar( builder.Build( ) );
		}

		public static long CreateCustomerRecordWith( string username ) {
			IInsertQueryBuilder builder = DatabaseInsert.Into( CustomerTable.TableName )
				.AddValue( CustomerTable.FirstName, string.Empty )
				.AddValue( CustomerTable.LastName, string.Empty )
				.AddValue( CustomerTable.Phone, string.Empty )
				.AddValue( CustomerTable.City, string.Empty );
			long customerId = Resolve.DependencyFor< IDatabaseGateway >( ).ExecuteScalar( builder.Build( ) );

			IQuery insertToAuthTable = DatabaseInsert.Into( AuthorizationTable.TableName )
				.AddValue( AuthorizationTable.UserName, username )
				.AddValue( AuthorizationTable.Password, string.Empty )
				.Build( );

			Resolve.DependencyFor< IDatabaseGateway >( ).Execute( insertToAuthTable );
			return customerId;
		}
	}
}