@@ -208,7 +208,7 @@ public async Task RefreshTests_RefreshIsNotSkippedIfCacheIsExpired()
208208 . Build ( ) ;
209209
210210 Assert . Equal ( "TestValue1" , config [ "TestKey1" ] ) ;
211- FirstKeyValue . Value = "newValue" ;
211+ _kvCollection [ 0 ] = TestHelpers . ChangeValue ( FirstKeyValue , "newValue" ) ;
212212
213213 // Wait for the cache to expire
214214 Thread . Sleep ( 1500 ) ;
@@ -221,7 +221,6 @@ public async Task RefreshTests_RefreshIsNotSkippedIfCacheIsExpired()
221221 [ Fact ]
222222 public async Task RefreshTests_RefreshAllFalseDoesNotUpdateEntireConfiguration ( )
223223 {
224- var keyValueCollection = new List < ConfigurationSetting > ( _kvCollection ) ;
225224 IConfigurationRefresher refresher = null ;
226225 var mockClient = GetMockConfigurationClient ( ) ;
227226
@@ -244,7 +243,7 @@ public async Task RefreshTests_RefreshAllFalseDoesNotUpdateEntireConfiguration()
244243 Assert . Equal ( "TestValue2" , config [ "TestKey2" ] ) ;
245244 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
246245
247- keyValueCollection . ForEach ( kv => kv . Value = "newValue" ) ;
246+ _kvCollection = _kvCollection . Select ( kv => TestHelpers . ChangeValue ( kv , "newValue" ) ) . ToList ( ) ;
248247
249248 // Wait for the cache to expire
250249 Thread . Sleep ( 1500 ) ;
@@ -259,7 +258,6 @@ public async Task RefreshTests_RefreshAllFalseDoesNotUpdateEntireConfiguration()
259258 [ Fact ]
260259 public async Task RefreshTests_RefreshAllTrueUpdatesEntireConfiguration ( )
261260 {
262- var keyValueCollection = new List < ConfigurationSetting > ( _kvCollection ) ;
263261 IConfigurationRefresher refresher = null ;
264262 var mockClient = GetMockConfigurationClient ( ) ;
265263
@@ -282,7 +280,7 @@ public async Task RefreshTests_RefreshAllTrueUpdatesEntireConfiguration()
282280 Assert . Equal ( "TestValue2" , config [ "TestKey2" ] ) ;
283281 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
284282
285- keyValueCollection . ForEach ( kv => kv . Value = "newValue" ) ;
283+ _kvCollection = _kvCollection . Select ( kv => TestHelpers . ChangeValue ( kv , "newValue" ) ) . ToList ( ) ;
286284
287285 // Wait for the cache to expire
288286 Thread . Sleep ( 1500 ) ;
@@ -353,7 +351,7 @@ Response<ConfigurationSetting> GetIfChanged(ConfigurationSetting setting, bool o
353351 Assert . Equal ( "TestValue2" , config [ "TestKey2" ] ) ;
354352 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
355353
356- keyValueCollection . First ( ) . Value = "newValue" ;
354+ keyValueCollection [ 0 ] = TestHelpers . ChangeValue ( keyValueCollection [ 0 ] , "newValue" ) ;
357355 keyValueCollection . Remove ( keyValueCollection . FirstOrDefault ( s => s . Key == "TestKey3" && s . Label == "label" ) ) ;
358356
359357 // Wait for the cache to expire
@@ -426,8 +424,8 @@ Response<ConfigurationSetting> GetIfChanged(ConfigurationSetting setting, bool o
426424 Assert . Equal ( "TestValue2" , config [ "TestKey2" ] ) ;
427425 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
428426
429- keyValueCollection . ElementAt ( 0 ) . Value = "newValue1" ;
430- keyValueCollection . ElementAt ( 1 ) . Value = "newValue2" ;
427+ keyValueCollection [ 0 ] = TestHelpers . ChangeValue ( keyValueCollection [ 0 ] , "newValue1" ) ;
428+ keyValueCollection [ 1 ] = TestHelpers . ChangeValue ( keyValueCollection [ 1 ] , "newValue2" ) ;
431429 keyValueCollection . Remove ( keyValueCollection . FirstOrDefault ( s => s . Key == "TestKey3" && s . Label == "label" ) ) ;
432430
433431 // Wait for the cache to expire
@@ -499,7 +497,7 @@ Response<ConfigurationSetting> GetIfChanged(ConfigurationSetting setting, bool o
499497 Assert . Equal ( "TestValue1" , config [ "TestKey1" ] ) ;
500498 Assert . Equal ( 1 , requestCount ) ;
501499
502- keyValueCollection . First ( ) . Value = "newValue" ;
500+ keyValueCollection [ 0 ] = TestHelpers . ChangeValue ( keyValueCollection [ 0 ] , "newValue" ) ;
503501
504502 // Simulate simultaneous refresh calls with expired cache from multiple threads
505503 var task1 = Task . Run ( ( ) => WaitAndRefresh ( refresher , 1500 ) ) ;
@@ -606,7 +604,7 @@ public async Task RefreshTests_TryRefreshAsyncUpdatesConfigurationAndReturnsTrue
606604 . Build ( ) ;
607605
608606 Assert . Equal ( "TestValue1" , config [ "TestKey1" ] ) ;
609- FirstKeyValue . Value = "newValue" ;
607+ _kvCollection [ 0 ] = TestHelpers . ChangeValue ( _kvCollection [ 0 ] , "newValue" ) ;
610608
611609 // Wait for the cache to expire
612610 Thread . Sleep ( 1500 ) ;
@@ -702,7 +700,7 @@ Response<ConfigurationSetting> GetIfChanged(ConfigurationSetting setting, bool o
702700 . Build ( ) ;
703701
704702 Assert . Equal ( "TestValue1" , config [ "TestKey1" ] ) ;
705- FirstKeyValue . Value = "newValue" ;
703+ _kvCollection [ 0 ] = TestHelpers . ChangeValue ( _kvCollection [ 0 ] , "newValue" ) ;
706704
707705 // Wait for the cache to expire
708706 Thread . Sleep ( 1500 ) ;
@@ -823,7 +821,7 @@ Response<ConfigurationSetting> GetIfChanged(ConfigurationSetting setting, bool o
823821 Assert . Equal ( "TestValue2" , config [ "TestKey2" ] ) ;
824822 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
825823
826- keyValueCollection . ForEach ( kv => kv . Value = "newValue" ) ;
824+ keyValueCollection = keyValueCollection . Select ( kv => TestHelpers . ChangeValue ( kv , "newValue" ) ) . ToList ( ) ;
827825
828826 // Wait for the cache to expire
829827 Thread . Sleep ( 1500 ) ;
@@ -874,7 +872,7 @@ public async Task RefreshTests_RefreshAllTrueForOverwrittenSentinelUpdatesEntire
874872 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
875873 Assert . Equal ( "TestValueForLabel2" , config [ "TestKeyWithMultipleLabels" ] ) ;
876874
877- keyValueCollection . ForEach ( kv => kv . Value = "newValue" ) ;
875+ _kvCollection = _kvCollection . Select ( kv => TestHelpers . ChangeValue ( kv , "newValue" ) ) . ToList ( ) ;
878876
879877 // Wait for the cache to expire
880878 Thread . Sleep ( 1500 ) ;
@@ -890,8 +888,7 @@ public async Task RefreshTests_RefreshAllTrueForOverwrittenSentinelUpdatesEntire
890888 [ Fact ]
891889 public async Task RefreshTests_RefreshAllFalseForOverwrittenSentinelUpdatesConfig ( )
892890 {
893- var keyValueCollection = new List < ConfigurationSetting > ( _kvCollection ) ;
894- ConfigurationSetting refreshRegisteredSetting = keyValueCollection . FirstOrDefault ( s => s . Key == "TestKeyWithMultipleLabels" && s . Label == "label1" ) ;
891+ ConfigurationSetting refreshRegisteredSetting = _kvCollection . FirstOrDefault ( s => s . Key == "TestKeyWithMultipleLabels" && s . Label == "label1" ) ;
895892 var mockClient = GetMockConfigurationClient ( ) ;
896893 IConfigurationRefresher refresher = null ;
897894
@@ -916,7 +913,7 @@ public async Task RefreshTests_RefreshAllFalseForOverwrittenSentinelUpdatesConfi
916913 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
917914 Assert . Equal ( "TestValueForLabel2" , config [ "TestKeyWithMultipleLabels" ] ) ;
918915
919- refreshRegisteredSetting . Value = "UpdatedValueForLabel1" ;
916+ _kvCollection [ _kvCollection . IndexOf ( refreshRegisteredSetting ) ] = TestHelpers . ChangeValue ( refreshRegisteredSetting , "UpdatedValueForLabel1" ) ;
920917
921918 // Wait for the cache to expire
922919 Thread . Sleep ( 1500 ) ;
@@ -933,8 +930,7 @@ public async Task RefreshTests_RefreshAllFalseForOverwrittenSentinelUpdatesConfi
933930 [ Fact ]
934931 public async Task RefreshTests_RefreshRegisteredKvOverwritesSelectedKv ( )
935932 {
936- var keyValueCollection = new List < ConfigurationSetting > ( _kvCollection ) ;
937- ConfigurationSetting refreshAllRegisteredSetting = keyValueCollection . FirstOrDefault ( s => s . Key == "TestKeyWithMultipleLabels" && s . Label == "label1" ) ;
933+ ConfigurationSetting refreshAllRegisteredSetting = _kvCollection . FirstOrDefault ( s => s . Key == "TestKeyWithMultipleLabels" && s . Label == "label1" ) ;
938934 var mockClient = GetMockConfigurationClient ( ) ;
939935 IConfigurationRefresher refresher = null ;
940936
@@ -959,7 +955,7 @@ public async Task RefreshTests_RefreshRegisteredKvOverwritesSelectedKv()
959955 Assert . Equal ( "TestValue3" , config [ "TestKey3" ] ) ;
960956 Assert . Equal ( "TestValueForLabel1" , config [ "TestKeyWithMultipleLabels" ] ) ;
961957
962- refreshAllRegisteredSetting . Value = "UpdatedValueForLabel1" ;
958+ _kvCollection [ _kvCollection . IndexOf ( refreshAllRegisteredSetting ) ] = TestHelpers . ChangeValue ( refreshAllRegisteredSetting , "UpdatedValueForLabel1" ) ;
963959
964960 // Wait for the cache to expire
965961 Thread . Sleep ( 1500 ) ;
0 commit comments