| File: AspireAzureAIInferenceEmbeddingsPublicApiTests.cs | Web Access |
| Project: src\tests\Aspire.Azure.AI.Inference.Tests\Aspire.Azure.AI.Inference.Tests.csproj (Aspire.Azure.AI.Inference.Tests) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Hosting; using Xunit; namespace Aspire.Azure.AI.Inference.Tests; public class AspireAzureAIInferenceEmbeddingsPublicApiTests { [Fact] public void AddEmbeddingsClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string connectionName = "aiembedding"; var action = () => builder.AddAzureEmbeddingsClient(connectionName); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddEmbeddingsClientShouldThrowWhenConnectionNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var connectionName = isNull ? null! : string.Empty; var action = () => builder.AddAzureEmbeddingsClient(connectionName); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(connectionName), exception.ParamName); } [Fact] public void AddKeyedEmbeddingsClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string name = "aiembedding"; var action = () => builder.AddKeyedAzureEmbeddingsClient(name); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddKeyedEmbeddingsClientShouldThrowWhenNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var name = isNull ? null! : string.Empty; var action = () => builder.AddKeyedAzureEmbeddingsClient(name); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(name), exception.ParamName); } }