Fix test failures by invalidating EditorConfigurationCache after setting EditorPrefs (#651)
Several tests were setting EditorPrefs values directly but not refreshing the EditorConfigurationCache singleton, causing it to return stale cached values. This led to tests expecting certain behavior (e.g., checking remote URL errors) but getting unexpected errors (e.g., "HTTP transport is disabled"). Added EditorConfigurationCache.Instance.Refresh() calls to: - ServerCommandBuilderTests.TryBuildCommand_RemoteUrl_ReturnsFalse() - ServerCommandBuilderTests.TryBuildCommand_LocalUrl_ReturnsCommandOrError() - ServerManagementServiceCharacterizationTests.TryGetLocalHttpServerCommand_RemoteUrl_ReturnsFalseWithError() - WriteToConfigTests.SetUp() This ensures the cache is refreshed when EditorPrefs are modified in tests. Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>main
parent
13aca5fb1c
commit
402eab56f9
|
|
@ -66,6 +66,7 @@ namespace MCPForUnityTests.Editor.Helpers
|
|||
// Force HTTP transport defaults so expectations match current behavior
|
||||
EditorPrefs.SetBool(UseHttpTransportPrefKey, true);
|
||||
EditorPrefs.SetString(HttpUrlPrefKey, "http://localhost:8080");
|
||||
EditorConfigCache.Instance.Refresh();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ namespace MCPForUnityTests.Editor.Services.Characterization
|
|||
// Arrange
|
||||
EditorPrefs.SetBool(EditorPrefKeys.UseHttpTransport, true);
|
||||
EditorPrefs.SetString(EditorPrefKeys.HttpBaseUrl, "http://remote.server.com:8080");
|
||||
EditorConfigurationCache.Instance.Refresh();
|
||||
_service = new ServerManagementService();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ namespace MCPForUnityTests.Editor.Services.Server
|
|||
// Arrange
|
||||
EditorPrefs.SetBool(EditorPrefKeys.UseHttpTransport, true);
|
||||
EditorPrefs.SetString(EditorPrefKeys.HttpBaseUrl, "http://remote.server.com:8080");
|
||||
EditorConfigurationCache.Instance.Refresh();
|
||||
|
||||
// Act
|
||||
bool result = _builder.TryBuildCommand(out string fileName, out string arguments, out string displayCommand, out string error);
|
||||
|
|
@ -253,6 +254,7 @@ namespace MCPForUnityTests.Editor.Services.Server
|
|||
// Arrange
|
||||
EditorPrefs.SetBool(EditorPrefKeys.UseHttpTransport, true);
|
||||
EditorPrefs.SetString(EditorPrefKeys.HttpBaseUrl, "http://localhost:8080");
|
||||
EditorConfigurationCache.Instance.Refresh();
|
||||
|
||||
// Act
|
||||
bool result = _builder.TryBuildCommand(out string fileName, out string arguments, out string displayCommand, out string error);
|
||||
|
|
|
|||
Loading…
Reference in New Issue