@@ -8,7 +8,6 @@ namespace Tester;
88[ TestCategory ( "BVT" ) ]
99public class StripedCallbackDictionaryTests
1010{
11- private static readonly GrainId Owner = GrainId . Create ( "test" , "owner" ) ;
1211 private static readonly Action < int , object ? > EmptyVisitor = static ( _ , _ ) => { } ;
1312
1413 [ Fact ]
@@ -36,27 +35,13 @@ public void AddGetAndRemovePreserveValue()
3635 var dictionary = new StripedCallbackDictionary < string > ( ) ;
3736 var id = new CorrelationId ( 42 ) ;
3837
39- Assert . True ( dictionary . TryAdd ( Owner , id , "value" ) ) ;
40- Assert . False ( dictionary . TryAdd ( Owner , id , "duplicate" ) ) ;
41- Assert . True ( dictionary . TryGetValue ( Owner , id , out var value ) ) ;
38+ Assert . True ( dictionary . TryAdd ( id , "value" ) ) ;
39+ Assert . False ( dictionary . TryAdd ( id , "duplicate" ) ) ;
40+ Assert . True ( dictionary . TryGetValue ( id , out var value ) ) ;
4241 Assert . Equal ( "value" , value ) ;
43- Assert . True ( dictionary . TryRemove ( Owner , id , out value ) ) ;
44- Assert . Equal ( "value" , value ) ;
45- Assert . False ( dictionary . TryGetValue ( Owner , id , out _ ) ) ;
46- }
47-
48- [ Fact ]
49- public void CallbackOwnerIsPartOfTheKey ( )
50- {
51- var dictionary = new StripedCallbackDictionary < string > ( ) ;
52- var otherOwner = GrainId . Create ( "test" , "other-owner" ) ;
53- var id = new CorrelationId ( 42 ) ;
54-
55- Assert . True ( dictionary . TryAdd ( Owner , id , "value" ) ) ;
56- Assert . False ( dictionary . TryGetValue ( otherOwner , id , out _ ) ) ;
57- Assert . False ( dictionary . TryRemove ( otherOwner , id , out _ ) ) ;
58- Assert . True ( dictionary . TryGetValue ( Owner , id , out var value ) ) ;
42+ Assert . True ( dictionary . TryRemove ( id , out value ) ) ;
5943 Assert . Equal ( "value" , value ) ;
44+ Assert . False ( dictionary . TryGetValue ( id , out _ ) ) ;
6045 }
6146
6247 [ Fact ]
@@ -66,7 +51,7 @@ public void EnumerationReturnsSnapshotValues()
6651 for ( var i = 0 ; i < 32 ; i ++ )
6752 {
6853 var id = new CorrelationId ( i ) ;
69- Assert . True ( dictionary . TryAdd ( Owner , id , i ) ) ;
54+ Assert . True ( dictionary . TryAdd ( id , i ) ) ;
7055 }
7156
7257 var values = new List < int > ( ) ;
@@ -83,8 +68,8 @@ public void ConcurrentOperationsPreserveCountAndValues()
8368 Parallel . For ( 0 , 10_000 , i =>
8469 {
8570 var id = new CorrelationId ( i ) ;
86- Assert . True ( dictionary . TryAdd ( Owner , id , i ) ) ;
87- Assert . True ( dictionary . TryGetValue ( Owner , id , out var value ) ) ;
71+ Assert . True ( dictionary . TryAdd ( id , i ) ) ;
72+ Assert . True ( dictionary . TryGetValue ( id , out var value ) ) ;
8873 Assert . Equal ( i , value ) ;
8974 } ) ;
9075
@@ -93,7 +78,7 @@ public void ConcurrentOperationsPreserveCountAndValues()
9378
9479 Parallel . For ( 0 , 10_000 , i =>
9580 {
96- Assert . True ( dictionary . TryRemove ( Owner , new CorrelationId ( i ) , out var value ) ) ;
81+ Assert . True ( dictionary . TryRemove ( new CorrelationId ( i ) , out var value ) ) ;
9782 Assert . Equal ( i , value ) ;
9883 } ) ;
9984
@@ -107,20 +92,20 @@ public void ConcurrentLookupAndRemovalRemainConsistent()
10792 var dictionary = new StripedCallbackDictionary < int > ( ) ;
10893 for ( var i = 0 ; i < count ; i ++ )
10994 {
110- Assert . True ( dictionary . TryAdd ( Owner , new CorrelationId ( i ) , i ) ) ;
95+ Assert . True ( dictionary . TryAdd ( new CorrelationId ( i ) , i ) ) ;
11196 }
11297
11398 Parallel . Invoke (
11499 ( ) => Parallel . For ( 0 , count , i =>
115100 {
116- if ( dictionary . TryGetValue ( Owner , new CorrelationId ( i ) , out var value ) )
101+ if ( dictionary . TryGetValue ( new CorrelationId ( i ) , out var value ) )
117102 {
118103 Assert . Equal ( i , value ) ;
119104 }
120105 } ) ,
121106 ( ) => Parallel . For ( 0 , count , i =>
122107 {
123- Assert . True ( dictionary . TryRemove ( Owner , new CorrelationId ( i ) , out var value ) ) ;
108+ Assert . True ( dictionary . TryRemove ( new CorrelationId ( i ) , out var value ) ) ;
124109 Assert . Equal ( i , value ) ;
125110 } ) ) ;
126111
@@ -133,12 +118,12 @@ public void SnapshotVisitorAllowsValuesToRemoveThemselves()
133118 var dictionary = new StripedCallbackDictionary < int > ( ) ;
134119 for ( var i = 0 ; i < 32 ; i ++ )
135120 {
136- Assert . True ( dictionary . TryAdd ( Owner , new CorrelationId ( i ) , i ) ) ;
121+ Assert . True ( dictionary . TryAdd ( new CorrelationId ( i ) , i ) ) ;
137122 }
138123
139- dictionary . ForEach ( ( Dictionary : dictionary , Owner ) , static ( value , state ) =>
124+ dictionary . ForEach ( dictionary , static ( value , dictionary ) =>
140125 {
141- Assert . True ( state . Dictionary . TryRemove ( state . Owner , new CorrelationId ( value ) , out var removed ) ) ;
126+ Assert . True ( dictionary . TryRemove ( new CorrelationId ( value ) , out var removed ) ) ;
142127 Assert . Equal ( value , removed ) ;
143128 } ) ;
144129
0 commit comments