@@ -1476,5 +1476,57 @@ Company Create()
1476
1476
Assert . That ( original . Address . City , Is . EqualTo ( defaults . Address . City ) ) ;
1477
1477
Assert . That ( original . Address . PostCode , Is . EqualTo ( "4321" ) ) ;
1478
1478
}
1479
+
1480
+ public class NavItem : IMeta
1481
+ {
1482
+ public string Label { get ; set ; }
1483
+ public string Path { get ; set ; }
1484
+
1485
+ /// <summary>
1486
+ /// Whether Active class should only be added when paths are exact match
1487
+ /// otherwise checks if ActivePath starts with Path
1488
+ /// </summary>
1489
+ public bool Exact { get ; set ; }
1490
+
1491
+ public string Id { get ; set ; } // Emit id="{Id}"
1492
+ public string Class { get ; set ; } // Override class="{Class}"
1493
+
1494
+ public List < NavItem > Children { get ; set ; } = new List < NavItem > ( ) ;
1495
+
1496
+ public Dictionary < string , string > Meta { get ; set ; } = new Dictionary < string , string > ( ) ;
1497
+ }
1498
+
1499
+ [ Test ]
1500
+ public void Does_convert_nested_collections ( )
1501
+ {
1502
+ var to = new [ ] {
1503
+ new Dictionary < string , object > {
1504
+ [ "id" ] = "A1" ,
1505
+ [ "children" ] = new List < object >
1506
+ {
1507
+ new Dictionary < string , object >
1508
+ {
1509
+ [ "id" ] = "B1" ,
1510
+ } ,
1511
+ new Dictionary < string , object >
1512
+ {
1513
+ [ "id" ] = "B2" ,
1514
+ [ "children" ] = new List < object > {
1515
+ new Dictionary < string , object >
1516
+ {
1517
+ [ "id" ] = "C1" ,
1518
+ } ,
1519
+ }
1520
+ } ,
1521
+ }
1522
+ }
1523
+ } ;
1524
+
1525
+ var navItems = to . ConvertTo < List < NavItem > > ( ) ;
1526
+ Assert . That ( navItems [ 0 ] . Id , Is . EqualTo ( "A1" ) ) ;
1527
+ Assert . That ( navItems [ 0 ] . Children [ 0 ] . Id , Is . EqualTo ( "B1" ) ) ;
1528
+ Assert . That ( navItems [ 0 ] . Children [ 1 ] . Id , Is . EqualTo ( "B2" ) ) ;
1529
+ Assert . That ( navItems [ 0 ] . Children [ 1 ] . Children [ 0 ] . Id , Is . EqualTo ( "C1" ) ) ;
1530
+ }
1479
1531
}
1480
1532
}
0 commit comments