77namespace TableStorage . Abstractions . POCO . Tests
88{
99 [ TestClass ]
10- public class PocoTableStoreTests
10+ public partial class PocoTableStoreTests
1111 {
1212 private PocoTableStore < Employee , int , int > tableStore ;
1313
@@ -1321,50 +1321,6 @@ public void update_record_with_calculated_partition_key_from_multiple_properties
13211321
13221322 }
13231323
1324- [ TestMethod ]
1325- public void get_record_with_calculated_partition_key_from_multiple_properties_using_extension_method ( )
1326- {
1327- KeyGenerator . DefineParitionKey ( typeof ( Employee ) , e=> $ "{ e . CompanyId } .{ e . DepartmentId } ") ;
1328- KeyGenerator . DefineRowKey ( typeof ( Employee ) , e => $ "{ e . Id } ") ;
1329-
1330- var pKeyMapper = new KeyMapper < Employee , int > ( e => $ "{ e . CompanyId } .{ e . Department . Id } ", null , null , null ) ;
1331- var rKeyMapper = new KeyMapper < Employee , int > ( e => e . Id . ToString ( ) , int . Parse , e => e . Id ,
1332- id => id . ToString ( ) ) ;
1333-
1334- var tableConverter = new CalculatedKeysTableConverter < Employee , int , int > ( pKeyMapper , rKeyMapper ) ;
1335-
1336- tableStore = new PocoTableStore < Employee , int , int > ( "TestEmployee" , "UseDevelopmentStorage=true" , tableConverter ) ;
1337-
1338-
1339- var employee = new Employee
1340- {
1341- CompanyId = 1 ,
1342- Id = 1 ,
1343- Name = "Mr. Jim CEO" ,
1344- Department = new Department { Id = 22 , Name = "Executive" }
1345- } ;
1346- tableStore . Insert ( employee ) ;
1347-
1348- var record = tableStore . GetRecord ( KeyGenerator . PartitionKey < Employee > ( new { CompanyId = 1 , DepartmentId = 22 } ) ,
1349- KeyGenerator . RowKey < Employee > ( new { Id = 1 } ) ) ;
1350-
1351- Assert . AreEqual ( 1 , record . Id ) ;
1352- Assert . AreEqual ( 22 , record . Department . Id ) ;
1353- Assert . AreEqual ( "Mr. Jim CEO" , record . Name ) ;
1354-
1355- }
1356-
1357- public class PartitionKey
1358- {
1359- public PartitionKey ( int companyId , int departmentId )
1360- {
1361- CompanyId = companyId ;
1362- DepartmentId = departmentId ;
1363- }
1364- public int CompanyId { get ; }
1365- public int DepartmentId { get ; }
1366- }
1367-
13681324
13691325 [ TestMethod ]
13701326 public void get_record_with_calculated_partition_key_from_multiple_properties_using_class_as_key ( )
@@ -1407,18 +1363,24 @@ public void get_record_with_calculated_partition_key_from_multiple_properties_us
14071363
14081364
14091365 [ TestMethod ]
1410- public void update_record_with_calculated_partition_key_from_multiple_properties_using_extension_method ( )
1366+ public void update_record_with_calculated_partition_key_from_multiple_properties_using_class_as_key ( )
14111367 {
1412- KeyGenerator . DefineParitionKey ( typeof ( Employee ) , e => $ "{ e . CompanyId } .{ e . DepartmentId } ") ;
1413- KeyGenerator . DefineRowKey ( typeof ( Employee ) , e => $ "{ e . Id } ") ;
14141368
1415- var pKeyMapper = new KeyMapper < Employee , int > ( e => $ "{ e . CompanyId } .{ e . Department . Id } ", null , null , null ) ;
1369+ var pKeyMapper = new CalculatedKeyMapper < Employee , PartitionKey > ( e => $ "{ e . CompanyId } .{ e . Department . Id } ", key =>
1370+ {
1371+ var parts = key . Split ( '.' ) ;
1372+ var companyId = int . Parse ( parts [ 0 ] ) ;
1373+ var departmentId = int . Parse ( parts [ 1 ] ) ;
1374+ return new PartitionKey ( companyId , departmentId ) ;
1375+ } , key => $ "{ key . CompanyId } .{ key . DepartmentId } ") ;
1376+
14161377 var rKeyMapper = new KeyMapper < Employee , int > ( e => e . Id . ToString ( ) , int . Parse , e => e . Id ,
14171378 id => id . ToString ( ) ) ;
14181379
1419- var tableConverter = new CalculatedKeysTableConverter < Employee , int , int > ( pKeyMapper , rKeyMapper ) ;
14201380
1421- tableStore = new PocoTableStore < Employee , int , int > ( "TestEmployee" , "UseDevelopmentStorage=true" , tableConverter ) ;
1381+ var tableConverter = new CalculatedKeysTableConverter < Employee , PartitionKey , int > ( pKeyMapper , rKeyMapper ) ;
1382+
1383+ var tableStore2 = new PocoTableStore < Employee , PartitionKey , int > ( "TestEmployee" , "UseDevelopmentStorage=true" , tableConverter ) ;
14221384
14231385
14241386 var employee = new Employee
@@ -1428,15 +1390,14 @@ public void update_record_with_calculated_partition_key_from_multiple_properties
14281390 Name = "Mr. Jim CEO" ,
14291391 Department = new Department { Id = 22 , Name = "Executive" }
14301392 } ;
1431- tableStore . Insert ( employee ) ;
1393+ tableStore2 . Insert ( employee ) ;
14321394
14331395 employee . Name = "Ted" ;
14341396
1435- tableStore . Update ( employee ) ;
1397+ tableStore2 . Update ( employee ) ;
14361398
1437- var record = tableStore . GetRecord (
1438- KeyGenerator . PartitionKey < Employee > ( new { CompanyId = 1 , DepartmentId = 22 } ) ,
1439- KeyGenerator . RowKey < Employee > ( new { Id = 1 } ) ) ;
1399+ var record = tableStore2 . GetRecord (
1400+ new PartitionKey ( 1 , 22 ) , 1 ) ;
14401401
14411402 Assert . AreEqual ( 1 , record . Id ) ;
14421403 Assert . AreEqual ( 22 , record . Department . Id ) ;
0 commit comments