From 4ba866670275d7d29325d9f7d3bf6b95990a6963 Mon Sep 17 00:00:00 2001 From: sikutisa Date: Wed, 11 Sep 2024 23:14:53 +0900 Subject: [PATCH] fix tests If a null secretName is given, a KeyNotFoundException is thrown instead of an InvalidOperationException. Related to: #300 --- .../Extensions/ServiceCollectionExtensionsTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/AzureOpenAIProxy.ApiApp.Tests/Extensions/ServiceCollectionExtensionsTests.cs b/test/AzureOpenAIProxy.ApiApp.Tests/Extensions/ServiceCollectionExtensionsTests.cs index 47cf8847..5a77eda8 100644 --- a/test/AzureOpenAIProxy.ApiApp.Tests/Extensions/ServiceCollectionExtensionsTests.cs +++ b/test/AzureOpenAIProxy.ApiApp.Tests/Extensions/ServiceCollectionExtensionsTests.cs @@ -108,9 +108,9 @@ public void Given_NullOrEmpty_VaultUri_When_Invoked_AddKeyVaultService_Then_It_S } [Theory] - [InlineData("http://localhost", default(string))] - [InlineData("http://localhost", "")] - public void Given_NullOrEmpty_SecretName_When_Invoked_AddKeyVaultService_Then_It_Should_Throw_Exception(string vaultUri, string? secretName) + [InlineData("http://localhost", default(string), typeof(KeyNotFoundException))] + [InlineData("http://localhost", "", typeof(InvalidOperationException))] + public void Given_NullOrEmpty_SecretName_When_Invoked_AddKeyVaultService_Then_It_Should_Throw_Exception(string vaultUri, string? secretName, Type exceptionType) { // Arrange var services = new ServiceCollection(); @@ -129,7 +129,7 @@ public void Given_NullOrEmpty_SecretName_When_Invoked_AddKeyVaultService_Then_It Action action = () => services.BuildServiceProvider().GetService(); // Assert - action.Should().Throw(); + action.Should().Throw().Which.Should().BeOfType(exceptionType); } [Theory]