@@ -1452,6 +1452,86 @@ public async Task TestGetActivitiesByForeignIDAndTime()
14521452 } ) ;
14531453 }
14541454
1455+ [ Test ]
1456+ public async Task TestGetEnrichedFlatActivitiesByID ( )
1457+ {
1458+ var userId = System . Guid . NewGuid ( ) . ToString ( ) ;
1459+ const string userName = "user name" ;
1460+ var user = await _client . Users . Add ( userId , new Dictionary < string , object > { [ "name" ] = userName } ) ;
1461+ var newActivity1 = new Stream . Activity ( user . Ref ( ) , "test" , "1" ) ;
1462+ var newActivity2 = new Stream . Activity ( user . Ref ( ) , "test" , "2" ) ;
1463+ var newActivity3 = new Stream . Activity ( user . Ref ( ) , "other" , "2" ) ;
1464+ var addedActivities = new List < Stream . Activity > ( ) ;
1465+
1466+ var response = await this . _user1 . AddActivity ( newActivity1 ) ;
1467+ addedActivities . Add ( response ) ;
1468+ response = await this . _user2 . AddActivity ( newActivity2 ) ;
1469+ addedActivities . Add ( response ) ;
1470+ response = await this . _flat3 . AddActivity ( newActivity3 ) ;
1471+ addedActivities . Add ( response ) ;
1472+
1473+ var activities = await this . _client . Batch . GetEnrichedFlatActivities ( addedActivities . Select ( a => a . Id ) ) ;
1474+ Assert . IsNotNull ( activities ) ;
1475+ Assert . AreEqual ( addedActivities . Count , activities . Count ( ) ) ;
1476+
1477+ activities . ForEach ( a =>
1478+ {
1479+ var found = addedActivities . Find ( x => x . Id == a . Id ) ;
1480+ Assert . NotNull ( found ) ;
1481+
1482+ Assert . IsTrue ( a . Actor . IsEnriched ) ;
1483+ Assert . AreEqual ( userId , a . Actor . Enriched . GetData < string > ( "id" ) ) ;
1484+ var userData = a . Actor . Enriched . GetData < Dictionary < string , object > > ( "data" ) ;
1485+ Assert . IsNotNull ( userData ) ;
1486+ Assert . IsTrue ( userData . ContainsKey ( "name" ) ) ;
1487+ Assert . AreEqual ( userName , userData [ "name" ] ) ;
1488+
1489+ Assert . IsFalse ( a . Object . IsEnriched ) ;
1490+ Assert . AreEqual ( found . Object , a . Object . Raw ) ;
1491+
1492+ Assert . IsFalse ( a . Verb . IsEnriched ) ;
1493+ Assert . AreEqual ( found . Verb , a . Verb . Raw ) ;
1494+ } ) ;
1495+ }
1496+
1497+ [ Test ]
1498+ public async Task TestGetEnrichedFlatActivitiesByIDWithReactions ( )
1499+ {
1500+ var userId = System . Guid . NewGuid ( ) . ToString ( ) ;
1501+ var user = await _client . Users . Add ( userId ) ;
1502+ var newActivity = new Stream . Activity ( user . Ref ( ) , "test" , "1" ) ;
1503+ newActivity = await this . _user1 . AddActivity ( newActivity ) ;
1504+
1505+ await _client . Reactions . Add ( "upvote" , newActivity . Id , user . ID , new Dictionary < string , object > { [ "reactionProp" ] = "reactionPropValue" } ) ;
1506+
1507+ var activities = await this . _client . Batch . GetEnrichedFlatActivities (
1508+ new [ ] { newActivity . Id } ,
1509+ reactions : ReactionOption . With ( ) . Counts ( ) . Recent ( ) ) ;
1510+
1511+ Assert . IsNotNull ( activities ) ;
1512+ Assert . AreEqual ( 1 , activities . Count ( ) ) ;
1513+
1514+ var enrichedActivity = activities . Single ( ) ;
1515+ Assert . NotNull ( enrichedActivity ) ;
1516+
1517+ Assert . IsTrue ( enrichedActivity . Actor . IsEnriched ) ;
1518+ Assert . AreEqual ( userId , enrichedActivity . Actor . Enriched . GetData < string > ( "id" ) ) ;
1519+
1520+ Assert . IsNotNull ( enrichedActivity . ReactionCounts ) ;
1521+ Assert . AreEqual ( 1 , enrichedActivity . ReactionCounts . Count ) ;
1522+ Assert . AreEqual ( "upvote" , enrichedActivity . ReactionCounts . Keys . Single ( ) ) ;
1523+ Assert . AreEqual ( 1 , enrichedActivity . ReactionCounts [ "upvote" ] ) ;
1524+
1525+ Assert . IsNotNull ( enrichedActivity . LatestReactions ) ;
1526+ Assert . AreEqual ( 1 , enrichedActivity . LatestReactions . Count ) ;
1527+ Assert . AreEqual ( "upvote" , enrichedActivity . LatestReactions . Keys . Single ( ) ) ;
1528+ Assert . AreEqual ( 1 , enrichedActivity . LatestReactions [ "upvote" ] . Count ( ) ) ;
1529+
1530+ var enrichedReaction = enrichedActivity . LatestReactions [ "upvote" ] . Single ( ) ;
1531+ Assert . IsNotNull ( enrichedReaction . Data ) ;
1532+ Assert . AreEqual ( "reactionPropValue" , enrichedReaction . Data [ "reactionProp" ] ) ;
1533+ }
1534+
14551535 [ Test ]
14561536 public void TestCollectionsUpsert ( )
14571537 {
@@ -2343,9 +2423,6 @@ public async Task TestEnrich_User_InReaction()
23432423 Assert . AreEqual ( true , ( bool ) ownReaction . User . Enriched ? . GetData < Dictionary < string , object > > ( "data" ) [ "is_admin" ] ) ;
23442424 }
23452425
2346-
2347-
2348-
23492426 [ Test ]
23502427 public async Task TestEnrich_LatestReactions ( )
23512428 {
0 commit comments