| File: AzureDataLakePublicApiTests.cs | Web Access |
| Project: src\tests\Aspire.Azure.Storage.Files.DataLake.Tests\Aspire.Azure.Storage.Files.DataLake.Tests.csproj (Aspire.Azure.Storage.Files.DataLake.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.Files.DataLake.Tests; public sealed class AzureDataLakePublicApiTests { [Fact] public void AddAzureDataLakeServiceClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string connectionName = "data-lake"; var action = () => builder.AddAzureDataLakeServiceClient(connectionName); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddAzureDataLakeServiceClientShouldThrowWhenConnectionNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var connectionName = isNull ? null! : string.Empty; var action = () => builder.AddAzureDataLakeServiceClient(connectionName); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(connectionName), exception.ParamName); } [Fact] public void AddKeyedAzureDataLakeServiceClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string name = "data-lake"; var action = () => builder.AddKeyedAzureDataLakeServiceClient(name); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddKeyedAzureDataLakeServiceClientShouldThrowWhenNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var name = isNull ? null! : string.Empty; var action = () => builder.AddKeyedAzureDataLakeServiceClient(name); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(name), exception.ParamName); } [Fact] public void AddAzureDataLakeFileSystemClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string connectionName = "data-lake-file-system"; var action = () => builder.AddAzureDataLakeFileSystemClient(connectionName); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddAzureDataLakeFileSystemClientShouldThrowWhenConnectionNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var connectionName = isNull ? null! : string.Empty; var action = () => builder.AddAzureDataLakeFileSystemClient(connectionName); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(connectionName), exception.ParamName); } [Fact] public void AddKeyedAzureDataLakeFileSystemClientShouldThrowWhenBuilderIsNull() { IHostApplicationBuilder builder = null!; const string name = "data-lake"; var action = () => builder.AddKeyedAzureDataLakeFileSystemClient(name); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal(nameof(builder), exception.ParamName); } [Theory] [InlineData(true)] [InlineData(false)] public void AddKeyedAzureDataLakeFileSystemClientShouldThrowWhenNameIsNullOrEmpty(bool isNull) { var builder = Host.CreateEmptyApplicationBuilder(null); var name = isNull ? null! : string.Empty; var action = () => builder.AddKeyedAzureDataLakeFileSystemClient(name); var exception = isNull ? Assert.Throws<ArgumentNullException>(action) : Assert.Throws<ArgumentException>(action); Assert.Equal(nameof(name), exception.ParamName); } [Fact] public void AzureDataLakeHealthCheckConstructorShouldThrowWhenClientIsNull() { var action = () => new AzureDataLakeStorageHealthCheck(null!); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal("dataLakeServiceClient", exception.ParamName); } [Fact] public void AzureDataLakeFileSystemHealthCheckConstructorShouldThrowWhenClientIsNull() { var action = () => new AzureDataLakeFileSystemHealthCheck(null!); var exception = Assert.Throws<ArgumentNullException>(action); Assert.Equal("dataLakeFileSystemClient", exception.ParamName); } }