| File: StorageQueuesPublicApiTests.cs | Web Access |
| Project: src\tests\Aspire.Azure.Storage.Queues.Tests\Aspire.Azure.Storage.Queues.Tests.csproj (Aspire.Azure.Storage.Queues.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.Queues.Tests; public class StorageQueuesPublicApiTests { [Fact] public void AddAzureQueueServiceClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string connectionName = "queue"; var action = () => builder.AddAzureQueueServiceClient(connectionName); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddAzureQueueServiceClientShouldThrowWhenConnectionNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var connectionName = isNull ? null! : string.Empty; var action = () => builder.AddAzureQueueServiceClient(connectionName); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(connectionName), exception.ParamName); } [Fact] public void AddKeyedAzureQueueServiceClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string name = "queue"; var action = () => builder.AddKeyedAzureQueueServiceClient(name); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddKeyedAzureQueueServiceClientShouldThrowWhenNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var name = isNull ? null! : string.Empty; var action = () => builder.AddKeyedAzureQueueServiceClient(name); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(name), exception.ParamName); } [Fact] public void AddAzureQueueClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string connectionName = "queue"; #pragma warning disable CS0618 // Type or member is obsolete var action = () => builder.AddAzureQueueServiceClient(connectionName); #pragma warning restore CS0618 // Type or member is obsolete var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddAzureQueueClientShouldThrowWhenConnectionNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var connectionName = isNull ? null! : string.Empty; #pragma warning disable CS0618 // Type or member is obsolete var action = () => builder.AddAzureQueueServiceClient(connectionName); #pragma warning restore CS0618 // Type or member is obsolete var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(connectionName), exception.ParamName); } [Fact] public void AddKeyedAzureQueueClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string name = "queue"; #pragma warning disable CS0618 // Type or member is obsolete var action = () => builder.AddKeyedAzureQueueServiceClient(name); #pragma warning restore CS0618 // Type or member is obsolete var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddKeyedAzureQueueClientShouldThrowWhenNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var name = isNull ? null! : string.Empty; #pragma warning disable CS0618 // Type or member is obsolete var action = () => builder.AddKeyedAzureQueueServiceClient(name); #pragma warning restore CS0618 // Type or member is obsolete var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(name), exception.ParamName); } }