77using System . Collections ;
88using System . Collections . Generic ;
99using System . Data . Common ;
10+ using System . Linq ;
1011
1112namespace SubSonic . Tests . DAL . SUT
1213{
@@ -56,6 +57,8 @@ public virtual void SetupTestFixture()
5657
5758 SetInsertBehaviors ( ) ;
5859
60+ SetSelectBehaviors ( ) ;
61+
5962 Statuses = new List < Status > ( )
6063 {
6164 new Status ( ) { ID = 1 , Name = "Vacant" , IsAvailableStatus = true } ,
@@ -73,11 +76,11 @@ public virtual void SetupTestFixture()
7376
7477 Renters = new List < Renter > ( )
7578 {
76- new Renter ( ) { PersonID = 1 , UnitID = 1 , StartDate = new DateTime ( 1980 , 01 , 01 ) , EndDate = new DateTime ( 1990 , 02 , 28 ) } ,
77- new Renter ( ) { PersonID = 2 , UnitID = 1 , StartDate = new DateTime ( 1990 , 03 , 01 ) } ,
78- new Renter ( ) { PersonID = 3 , UnitID = 2 , StartDate = new DateTime ( 1980 , 03 , 01 ) , EndDate = new DateTime ( 2000 , 01 , 01 ) } ,
79- new Renter ( ) { PersonID = 1 , UnitID = 3 , StartDate = new DateTime ( 1990 , 03 , 01 ) } ,
80- new Renter ( ) { PersonID = 4 , UnitID = 4 , StartDate = new DateTime ( 2000 , 01 , 01 ) }
79+ new Renter ( ) { PersonID = 1 , UnitID = 1 , Rent = 100M , StartDate = new DateTime ( 1980 , 01 , 01 ) , EndDate = new DateTime ( 1990 , 02 , 28 ) } ,
80+ new Renter ( ) { PersonID = 2 , UnitID = 1 , Rent = 150M , StartDate = new DateTime ( 1990 , 03 , 01 ) } ,
81+ new Renter ( ) { PersonID = 3 , UnitID = 2 , Rent = 200M , StartDate = new DateTime ( 1980 , 03 , 01 ) , EndDate = new DateTime ( 2000 , 01 , 01 ) } ,
82+ new Renter ( ) { PersonID = 1 , UnitID = 3 , Rent = 250M , StartDate = new DateTime ( 1990 , 03 , 01 ) } ,
83+ new Renter ( ) { PersonID = 4 , UnitID = 4 , Rent = 300M , StartDate = new DateTime ( 2000 , 01 , 01 ) }
8184 } ;
8285
8386 RealEstateProperties = new List < RealEstateProperty > ( )
@@ -97,7 +100,39 @@ public virtual void SetupTestFixture()
97100 } ;
98101 }
99102
100- private void SetInsertBehaviors ( )
103+ protected virtual void SetSelectBehaviors ( )
104+ {
105+ string
106+ people_all = @"SELECT [T1].[ID], [T1].[FirstName], [T1].[MiddleInitial], [T1].[FamilyName], [T1].[FullName]
107+ FROM [dbo].[Person] AS [T1]" ,
108+ people_all_count = @"SELECT COUNT([T1].[ID])
109+ FROM [dbo].[Person] AS [T1]" ,
110+ people_all_long_count = @"SELECT COUNT_BIG([T1].[ID])
111+ FROM [dbo].[Person] AS [T1]" ,
112+ people_equal = @"SELECT [T1].[ID], [T1].[FirstName], [T1].[MiddleInitial], [T1].[FamilyName], [T1].[FullName]
113+ FROM [dbo].[Person] AS [T1]
114+ WHERE ([T1].[ID] = @id_1)" ,
115+ people_greater_than = @"SELECT [T1].[ID], [T1].[FirstName], [T1].[MiddleInitial], [T1].[FamilyName], [T1].[FullName]
116+ FROM [dbo].[Person] AS [T1]
117+ WHERE ([T1].[ID] > @id_1)" ,
118+ people_less_than = @"SELECT [T1].[ID], [T1].[FirstName], [T1].[MiddleInitial], [T1].[FamilyName], [T1].[FullName]
119+ FROM [dbo].[Person] AS [T1]
120+ WHERE ([T1].[ID] < @id_1)" ,
121+ renter_byperson = @"SELECT [T1].[PersonID], [T1].[UnitID], [T1].[Rent], [T1].[StartDate], [T1].[EndDate]
122+ FROM [dbo].[Renter] AS [T1]
123+ WHERE ([T1].[PersonID] == @personid_1)" ;
124+
125+ Context . Database . Instance . AddCommandBehavior ( people_all , cmd => People . ToDataTable ( ) ) ;
126+ Context . Database . Instance . AddCommandBehavior ( people_all_count , cmd => People . Count ( ) ) ;
127+ Context . Database . Instance . AddCommandBehavior ( people_all_long_count , cmd => People . LongCount ( ) ) ;
128+ Context . Database . Instance . AddCommandBehavior ( people_greater_than , cmd => People . Where ( x => x . ID > cmd . Parameters [ "@id_1" ] . GetValue < int > ( ) ) . ToDataTable ( ) ) ;
129+ Context . Database . Instance . AddCommandBehavior ( people_equal , cmd => People . Where ( x => x . ID == cmd . Parameters [ "@id_1" ] . GetValue < int > ( ) ) . ToDataTable ( ) ) ;
130+ Context . Database . Instance . AddCommandBehavior ( people_less_than , cmd => People . Where ( x => x . ID < cmd . Parameters [ "@id_1" ] . GetValue < int > ( ) ) . ToDataTable ( ) ) ;
131+
132+ Context . Database . Instance . AddCommandBehavior ( renter_byperson , cmd => Renters . Where ( x => x . PersonID == cmd . Parameters [ "@personid_1" ] . GetValue < int > ( ) ) . ToDataTable ( ) ) ;
133+ }
134+
135+ protected virtual void SetInsertBehaviors ( )
101136 {
102137 string
103138 insert_person = @"INSERT INTO [dbo].[Person]
0 commit comments