Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions DevProxy.Integration.Tests/ApiCenterClientTests.cs
Original file line number Diff line number Diff line change
@@ -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<ArgumentException>(() =>
new ApiCenterClient(configuration, NullLogger<ApiCenterClient>.Instance));

Assert.Equal($"Specify {missingKey} in the configuration.", ex.Message);
}
}
8 changes: 4 additions & 4 deletions DevProxy.Plugins/ApiCenter/ApiCenterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ internal ApiCenterClient(ApiCenterClientConfiguration configuration, ILogger<Api
{
if (string.IsNullOrEmpty(configuration.SubscriptionId))
{
throw new ArgumentException($"Specify {nameof(ApiCenterClientConfiguration.SubscriptionId)} in the configuration.");
throw new ArgumentException("Specify subscriptionId in the configuration.");
}
if (string.IsNullOrEmpty(configuration.ResourceGroupName))
{
throw new ArgumentException($"Specify {nameof(ApiCenterClientConfiguration.ResourceGroupName)} in the configuration.");
throw new ArgumentException("Specify resourceGroupName in the configuration.");
}
if (string.IsNullOrEmpty(configuration.ServiceName))
{
throw new ArgumentException($"Specify {nameof(ApiCenterClientConfiguration.ServiceName)} in the configuration.");
throw new ArgumentException("Specify serviceName in the configuration.");
}
if (string.IsNullOrEmpty(configuration.WorkspaceName))
{
throw new ArgumentException($"Specify {nameof(ApiCenterClientConfiguration.WorkspaceName)} in the configuration.");
throw new ArgumentException("Specify workspaceName in the configuration.");
}

// load configuration from env vars
Expand Down
Loading