| File: StorageBlobsPublicApiTests.cs | Web Access |
| Project: src\tests\Aspire.Azure.Storage.Blobs.Tests\Aspire.Azure.Storage.Blobs.Tests.csproj (Aspire.Azure.Storage.Blobs.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.Storage.Blobs.Tests; public class StorageBlobsPublicApiTests { [Fact] public void AddAzureBlobClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string connectionName = "blobs"; var action = () => builder.AddAzureBlobServiceClient(connectionName); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddAzureBlobClientShouldThrowWhenConnectionNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var connectionName = isNull ? null! : string.Empty; var action = () => builder.AddAzureBlobServiceClient(connectionName); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(connectionName), exception.ParamName); } [Fact] public void AddKeyedAzureBlobClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string name = "blobs"; var action = () => builder.AddKeyedAzureBlobServiceClient(name); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddKeyedAzureBlobClientShouldThrowWhenNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var name = isNull ? null! : string.Empty; var action = () => builder.AddKeyedAzureBlobServiceClient(name); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(name), exception.ParamName); } }