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