From b2502be6758a41d4621f074a10a17cd2cb69ff4d Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Mon, 7 Sep 2026 18:30:10 +0200 Subject: [PATCH] Fix configuration reload test race Wait for both the expected configuration value and the root reload token before continuing to the next file operation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../tests/FunctionalTests/ConfigurationTests.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration/tests/FunctionalTests/ConfigurationTests.cs b/src/libraries/Microsoft.Extensions.Configuration/tests/FunctionalTests/ConfigurationTests.cs index 937d8d5b7e1e8f..524e9ca3cd34c5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration/tests/FunctionalTests/ConfigurationTests.cs +++ b/src/libraries/Microsoft.Extensions.Configuration/tests/FunctionalTests/ConfigurationTests.cs @@ -840,7 +840,7 @@ public async Task DeletingFilesThatRedefineKeysWithReload(bool optional) _fileSystem.DeleteFile(_iniFile); await WaitForChange( - () => config["Key"] == "JsonValue1", + () => config["Key"] == "JsonValue1" && token.HasChanged, "Notification failed for deleting ini file."); Assert.Equal("JsonValue1", config["Key"]); @@ -850,7 +850,7 @@ await WaitForChange( _fileSystem.DeleteFile(_jsonFile); await WaitForChange( - () => config["Key"] == "XmlValue1", + () => config["Key"] == "XmlValue1" && token.HasChanged, "Notification failed for deleting JSON file."); Assert.Equal("XmlValue1", config["Key"]); @@ -860,7 +860,7 @@ await WaitForChange( _fileSystem.DeleteFile(_xmlFile); await WaitForChange( - () => config["Key"] == null, + () => config["Key"] is null && token.HasChanged, "Notification failed for deleting XML file."); Assert.Null(config["Key"]); @@ -870,7 +870,7 @@ await WaitForChange( _fileSystem.WriteFile(_jsonFile, @"{""Key"": ""JsonValue1""}"); await WaitForChange( - () => config["Key"] == "JsonValue1", + () => config["Key"] == "JsonValue1" && token.HasChanged, "Notification failed for re-creating JSON file."); Assert.Equal("JsonValue1", config["Key"]); @@ -891,7 +891,7 @@ await WaitForChange( _fileSystem.WriteFile(_iniFile, @"Key = IniValue1"); await WaitForChange( - () => config["Key"] == "IniValue1", + () => config["Key"] == "IniValue1" && token.HasChanged, "Notification failed for re-creating ini file."); Assert.Equal("IniValue1", config["Key"]);