From 1f96cf3aebc617f2585aa579aaee1f0bd865e494 Mon Sep 17 00:00:00 2001 From: Waldek Mastykarz Date: Wed, 21 Oct 2026 15:54:40 +0200 Subject: [PATCH] Use config key names in API Center validation errors Error messages now reference camelCase config keys (subscriptionId, resourceGroupName, serviceName, workspaceName) instead of PascalCase property names. Closes #1969 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2bc25ec3-3ffb-4816-84ef-3f33c88a2c57 --- .../ApiCenterClientTests.cs | 33 +++++++++++++++++++ DevProxy.Plugins/ApiCenter/ApiCenterClient.cs | 8 ++--- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 DevProxy.Integration.Tests/ApiCenterClientTests.cs diff --git a/DevProxy.Integration.Tests/ApiCenterClientTests.cs b/DevProxy.Integration.Tests/ApiCenterClientTests.cs new file mode 100644 index 000000000..7c27ec1b2 --- /dev/null +++ b/DevProxy.Integration.Tests/ApiCenterClientTests.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using DevProxy.Plugins.ApiCenter; +using Microsoft.Extensions.Logging.Abstractions; +using Xunit; + +namespace DevProxy.Integration.Tests; + +public sealed class ApiCenterClientTests +{ + [Theory] + [InlineData("subscriptionId")] + [InlineData("resourceGroupName")] + [InlineData("serviceName")] + [InlineData("workspaceName")] + public void Constructor_MissingSetting_ErrorUsesConfigKeyName(string missingKey) + { + var configuration = new ApiCenterClientConfiguration + { + SubscriptionId = missingKey == "subscriptionId" ? "" : "sub", + ResourceGroupName = missingKey == "resourceGroupName" ? "" : "rg", + ServiceName = missingKey == "serviceName" ? "" : "svc", + WorkspaceName = missingKey == "workspaceName" ? "" : "default" + }; + + var ex = Assert.Throws(() => + new ApiCenterClient(configuration, NullLogger.Instance)); + + Assert.Equal($"Specify {missingKey} in the configuration.", ex.Message); + } +} diff --git a/DevProxy.Plugins/ApiCenter/ApiCenterClient.cs b/DevProxy.Plugins/ApiCenter/ApiCenterClient.cs index 0116c9bdc..f267482de 100644 --- a/DevProxy.Plugins/ApiCenter/ApiCenterClient.cs +++ b/DevProxy.Plugins/ApiCenter/ApiCenterClient.cs @@ -40,19 +40,19 @@ internal ApiCenterClient(ApiCenterClientConfiguration configuration, ILogger