From 975a9fc37c714a55b0e3320d480667939d6c73fb Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 24 Jul 2024 16:13:37 -0500 Subject: [PATCH] Extract Aspire.Hosting.Azure.Tests (#5013) Contributes to #4294 This also allows us to remove the Aspire.Hosting.Tests.SharedShim, now that VolumeNameGenerator is only found in Aspire.Hosting. --- Aspire.sln | 14 ++++---- ...pire.Hosting.Azure.AppConfiguration.csproj | 4 --- ...e.Hosting.Azure.ApplicationInsights.csproj | 4 --- ...ire.Hosting.Azure.CognitiveServices.csproj | 4 --- .../Aspire.Hosting.Azure.CosmosDB.csproj | 4 --- .../AzureCosmosDBEmulatorConnectionString.cs | 11 ++++++ .../AzureCosmosDBResource.cs | 5 --- .../Aspire.Hosting.Azure.KeyVault.csproj | 4 --- ...e.Hosting.Azure.OperationalInsights.csproj | 4 --- .../Aspire.Hosting.Azure.PostgreSQL.csproj | 4 --- .../Aspire.Hosting.Azure.Redis.csproj | 4 --- .../Aspire.Hosting.Azure.Search.csproj | 4 --- .../Aspire.Hosting.Azure.ServiceBus.csproj | 4 --- .../Aspire.Hosting.Azure.SignalR.csproj | 4 --- .../Aspire.Hosting.Azure.Sql.csproj | 4 --- .../Aspire.Hosting.Azure.Storage.csproj | 4 --- .../AzureStorageEmulatorConnectionString.cs | 36 +++++++++++++++++++ .../AzureStorageResource.cs | 31 ---------------- .../Aspire.Hosting.Azure.WebPubSub.csproj | 4 --- .../Aspire.Hosting.Azure.csproj | 2 +- src/Aspire.Hosting.Azure/Exceptions.cs | 4 +-- .../Aspire.Hosting.Azure.Tests.csproj | 31 ++++++++++++++++ .../AzureBicepProvisionerTests.cs | 8 +++-- .../AzureBicepResourceTests.cs | 10 +++--- .../AzureEventHubsExtensionsTests.cs | 3 +- .../AzureResourceExtensionsTests.cs | 3 +- .../AzureSchemaTests.cs | 19 ++++++++++ .../ResourceGroupNameHelpersTests.cs | 2 +- .../Aspire.Hosting.Tests.SharedShim.csproj | 21 ----------- .../Aspire.Hosting.Tests.csproj | 18 ---------- .../Schema/SchemaTests.cs | 6 ---- .../Utils/VolumeNameGeneratorTests.cs | 4 +-- 32 files changed, 122 insertions(+), 162 deletions(-) create mode 100644 src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBEmulatorConnectionString.cs create mode 100644 src/Aspire.Hosting.Azure.Storage/AzureStorageEmulatorConnectionString.cs create mode 100644 tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj rename tests/{Aspire.Hosting.Tests/Azure => Aspire.Hosting.Azure.Tests}/AzureBicepProvisionerTests.cs (97%) rename tests/{Aspire.Hosting.Tests/Azure => Aspire.Hosting.Azure.Tests}/AzureBicepResourceTests.cs (99%) rename tests/{Aspire.Hosting.Tests/Azure => Aspire.Hosting.Azure.Tests}/AzureEventHubsExtensionsTests.cs (98%) rename tests/{Aspire.Hosting.Tests/Azure => Aspire.Hosting.Azure.Tests}/AzureResourceExtensionsTests.cs (98%) create mode 100644 tests/Aspire.Hosting.Azure.Tests/AzureSchemaTests.cs rename tests/{Aspire.Hosting.Tests/Azure => Aspire.Hosting.Azure.Tests}/ResourceGroupNameHelpersTests.cs (95%) delete mode 100644 tests/Aspire.Hosting.Tests.SharedShim/Aspire.Hosting.Tests.SharedShim.csproj diff --git a/Aspire.sln b/Aspire.sln index b9bbcf39d9..4e4c57ae80 100644 --- a/Aspire.sln +++ b/Aspire.sln @@ -445,8 +445,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qdrant.ApiService", "playgr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Azure.EventHubs", "src\Aspire.Hosting.Azure.EventHubs\Aspire.Hosting.Azure.EventHubs.csproj", "{2580B014-E7FE-48D9-BE40-E90604365F0E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Tests.SharedShim", "tests\Aspire.Hosting.Tests.SharedShim\Aspire.Hosting.Tests.SharedShim.csproj", "{74644A4D-8F61-4314-B6E8-5CE3802CD6C2}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Azure.KeyVault", "src\Aspire.Hosting.Azure.KeyVault\Aspire.Hosting.Azure.KeyVault.csproj", "{427F4D7C-8969-4015-AD1A-5EFFE921A184}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Qdrant.Client", "src\Components\Aspire.Qdrant.Client\Aspire.Qdrant.Client.csproj", "{E0E1B557-D3CF-4446-B993-E5CE719234FB}" @@ -551,6 +549,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Keycloak.Tes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Keycloak.Authentication.Tests", "tests\Aspire.Keycloak.Authentication.Tests\Aspire.Keycloak.Authentication.Tests.csproj", "{48FF09E9-7D33-4A3F-9FF2-4C43A219C7B7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Azure.Tests", "tests\Aspire.Hosting.Azure.Tests\Aspire.Hosting.Azure.Tests.csproj", "{8691F993-7B19-496E-B8E1-EF1199ACF2E1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1269,10 +1269,6 @@ Global {2580B014-E7FE-48D9-BE40-E90604365F0E}.Debug|Any CPU.Build.0 = Debug|Any CPU {2580B014-E7FE-48D9-BE40-E90604365F0E}.Release|Any CPU.ActiveCfg = Release|Any CPU {2580B014-E7FE-48D9-BE40-E90604365F0E}.Release|Any CPU.Build.0 = Release|Any CPU - {74644A4D-8F61-4314-B6E8-5CE3802CD6C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {74644A4D-8F61-4314-B6E8-5CE3802CD6C2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {74644A4D-8F61-4314-B6E8-5CE3802CD6C2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {74644A4D-8F61-4314-B6E8-5CE3802CD6C2}.Release|Any CPU.Build.0 = Release|Any CPU {427F4D7C-8969-4015-AD1A-5EFFE921A184}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {427F4D7C-8969-4015-AD1A-5EFFE921A184}.Debug|Any CPU.Build.0 = Debug|Any CPU {427F4D7C-8969-4015-AD1A-5EFFE921A184}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1457,6 +1453,10 @@ Global {48FF09E9-7D33-4A3F-9FF2-4C43A219C7B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {48FF09E9-7D33-4A3F-9FF2-4C43A219C7B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {48FF09E9-7D33-4A3F-9FF2-4C43A219C7B7}.Release|Any CPU.Build.0 = Release|Any CPU + {8691F993-7B19-496E-B8E1-EF1199ACF2E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8691F993-7B19-496E-B8E1-EF1199ACF2E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8691F993-7B19-496E-B8E1-EF1199ACF2E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8691F993-7B19-496E-B8E1-EF1199ACF2E1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1669,7 +1669,6 @@ Global {F43586B8-FE36-490D-9EFA-82CFFB83A304} = {A4800EE3-F902-4B7B-AF53-01A85514E6B9} {6B6D3953-E961-4720-B27E-9466A69BED1A} = {A4800EE3-F902-4B7B-AF53-01A85514E6B9} {2580B014-E7FE-48D9-BE40-E90604365F0E} = {77CFE74A-32EE-400C-8930-5025E8555256} - {74644A4D-8F61-4314-B6E8-5CE3802CD6C2} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60} {427F4D7C-8969-4015-AD1A-5EFFE921A184} = {77CFE74A-32EE-400C-8930-5025E8555256} {E0E1B557-D3CF-4446-B993-E5CE719234FB} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2} {A9CFA376-0C90-4231-9152-FBF14065195A} = {C424395C-1235-41A4-BF55-07880A04368C} @@ -1725,6 +1724,7 @@ Global {C556D61C-7E11-43EC-9098-C8D170FEA905} = {EBC55A17-B0D6-4E0A-9DC2-7D264E96F631} {5867BAF2-FEF0-4661-BFDE-9ADCDC2921CD} = {830A89EC-4029-4753-B25A-068BAE37DEC7} {48FF09E9-7D33-4A3F-9FF2-4C43A219C7B7} = {C424395C-1235-41A4-BF55-07880A04368C} + {8691F993-7B19-496E-B8E1-EF1199ACF2E1} = {830A89EC-4029-4753-B25A-068BAE37DEC7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C} diff --git a/src/Aspire.Hosting.Azure.AppConfiguration/Aspire.Hosting.Azure.AppConfiguration.csproj b/src/Aspire.Hosting.Azure.AppConfiguration/Aspire.Hosting.Azure.AppConfiguration.csproj index a9e2e85286..2a51aa2622 100644 --- a/src/Aspire.Hosting.Azure.AppConfiguration/Aspire.Hosting.Azure.AppConfiguration.csproj +++ b/src/Aspire.Hosting.Azure.AppConfiguration/Aspire.Hosting.Azure.AppConfiguration.csproj @@ -18,8 +18,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.ApplicationInsights/Aspire.Hosting.Azure.ApplicationInsights.csproj b/src/Aspire.Hosting.Azure.ApplicationInsights/Aspire.Hosting.Azure.ApplicationInsights.csproj index 9752d5e09a..c2e9317001 100644 --- a/src/Aspire.Hosting.Azure.ApplicationInsights/Aspire.Hosting.Azure.ApplicationInsights.csproj +++ b/src/Aspire.Hosting.Azure.ApplicationInsights/Aspire.Hosting.Azure.ApplicationInsights.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.CognitiveServices/Aspire.Hosting.Azure.CognitiveServices.csproj b/src/Aspire.Hosting.Azure.CognitiveServices/Aspire.Hosting.Azure.CognitiveServices.csproj index 734b2f67f6..c0abd55dac 100644 --- a/src/Aspire.Hosting.Azure.CognitiveServices/Aspire.Hosting.Azure.CognitiveServices.csproj +++ b/src/Aspire.Hosting.Azure.CognitiveServices/Aspire.Hosting.Azure.CognitiveServices.csproj @@ -18,8 +18,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.CosmosDB/Aspire.Hosting.Azure.CosmosDB.csproj b/src/Aspire.Hosting.Azure.CosmosDB/Aspire.Hosting.Azure.CosmosDB.csproj index 2d5a0cffe8..a699bf91f0 100644 --- a/src/Aspire.Hosting.Azure.CosmosDB/Aspire.Hosting.Azure.CosmosDB.csproj +++ b/src/Aspire.Hosting.Azure.CosmosDB/Aspire.Hosting.Azure.CosmosDB.csproj @@ -22,8 +22,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBEmulatorConnectionString.cs b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBEmulatorConnectionString.cs new file mode 100644 index 0000000000..8273fbfc23 --- /dev/null +++ b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBEmulatorConnectionString.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Hosting.Azure.Cosmos; + +namespace Aspire.Hosting.Azure; + +internal static class AzureCosmosDBEmulatorConnectionString +{ + public static string Create(int port) => $"AccountKey={CosmosConstants.EmulatorAccountKey};AccountEndpoint=https://127.0.0.1:{port};DisableServerCertificateValidation=True;"; +} diff --git a/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs index fdae6cccae..af24a5a0d9 100644 --- a/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs +++ b/src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs @@ -3,7 +3,6 @@ using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.Azure; -using Aspire.Hosting.Azure.Cosmos; namespace Aspire.Hosting; @@ -38,7 +37,3 @@ public class AzureCosmosDBResource(string name, Action : ReferenceExpression.Create($"{ConnectionString}"); } -internal static class AzureCosmosDBEmulatorConnectionString -{ - public static string Create(int port) => $"AccountKey={CosmosConstants.EmulatorAccountKey};AccountEndpoint=https://127.0.0.1:{port};DisableServerCertificateValidation=True;"; -} diff --git a/src/Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.KeyVault.csproj b/src/Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.KeyVault.csproj index aafed3e38b..fb43f31ac4 100644 --- a/src/Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.KeyVault.csproj +++ b/src/Aspire.Hosting.Azure.KeyVault/Aspire.Hosting.Azure.KeyVault.csproj @@ -18,8 +18,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.OperationalInsights/Aspire.Hosting.Azure.OperationalInsights.csproj b/src/Aspire.Hosting.Azure.OperationalInsights/Aspire.Hosting.Azure.OperationalInsights.csproj index a56ddf2a7b..560047bba3 100644 --- a/src/Aspire.Hosting.Azure.OperationalInsights/Aspire.Hosting.Azure.OperationalInsights.csproj +++ b/src/Aspire.Hosting.Azure.OperationalInsights/Aspire.Hosting.Azure.OperationalInsights.csproj @@ -18,8 +18,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.PostgreSQL.csproj b/src/Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.PostgreSQL.csproj index a25d8330a1..3b509b641a 100644 --- a/src/Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.PostgreSQL.csproj +++ b/src/Aspire.Hosting.Azure.PostgreSQL/Aspire.Hosting.Azure.PostgreSQL.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.Redis/Aspire.Hosting.Azure.Redis.csproj b/src/Aspire.Hosting.Azure.Redis/Aspire.Hosting.Azure.Redis.csproj index aef6711096..db0f5e1e1b 100644 --- a/src/Aspire.Hosting.Azure.Redis/Aspire.Hosting.Azure.Redis.csproj +++ b/src/Aspire.Hosting.Azure.Redis/Aspire.Hosting.Azure.Redis.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.Search/Aspire.Hosting.Azure.Search.csproj b/src/Aspire.Hosting.Azure.Search/Aspire.Hosting.Azure.Search.csproj index 17096b7988..0244eaf899 100644 --- a/src/Aspire.Hosting.Azure.Search/Aspire.Hosting.Azure.Search.csproj +++ b/src/Aspire.Hosting.Azure.Search/Aspire.Hosting.Azure.Search.csproj @@ -18,8 +18,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.ServiceBus/Aspire.Hosting.Azure.ServiceBus.csproj b/src/Aspire.Hosting.Azure.ServiceBus/Aspire.Hosting.Azure.ServiceBus.csproj index 41d990fe49..9bd97f7152 100644 --- a/src/Aspire.Hosting.Azure.ServiceBus/Aspire.Hosting.Azure.ServiceBus.csproj +++ b/src/Aspire.Hosting.Azure.ServiceBus/Aspire.Hosting.Azure.ServiceBus.csproj @@ -18,8 +18,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.SignalR/Aspire.Hosting.Azure.SignalR.csproj b/src/Aspire.Hosting.Azure.SignalR/Aspire.Hosting.Azure.SignalR.csproj index 8356bea5ed..f8b98c4d45 100644 --- a/src/Aspire.Hosting.Azure.SignalR/Aspire.Hosting.Azure.SignalR.csproj +++ b/src/Aspire.Hosting.Azure.SignalR/Aspire.Hosting.Azure.SignalR.csproj @@ -18,8 +18,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj b/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj index 97bb4f2495..27da84f9b8 100644 --- a/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj +++ b/src/Aspire.Hosting.Azure.Sql/Aspire.Hosting.Azure.Sql.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.Storage.csproj b/src/Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.Storage.csproj index 432667c93f..f8eed3a2c0 100644 --- a/src/Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.Storage.csproj +++ b/src/Aspire.Hosting.Azure.Storage/Aspire.Hosting.Azure.Storage.csproj @@ -22,8 +22,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure.Storage/AzureStorageEmulatorConnectionString.cs b/src/Aspire.Hosting.Azure.Storage/AzureStorageEmulatorConnectionString.cs new file mode 100644 index 0000000000..3d62d1b633 --- /dev/null +++ b/src/Aspire.Hosting.Azure.Storage/AzureStorageEmulatorConnectionString.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Globalization; +using System.Text; + +namespace Aspire.Hosting.Azure; + +internal static class AzureStorageEmulatorConnectionString +{ + // Use defaults from https://learn.microsoft.com/azure/storage/common/storage-configure-connection-string#connect-to-the-emulator-account-using-the-shortcut + private const string ConnectionStringHeader = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;"; + private const string BlobEndpointTemplate = "BlobEndpoint=http://127.0.0.1:{0}/devstoreaccount1;"; + private const string QueueEndpointTemplate = "QueueEndpoint=http://127.0.0.1:{0}/devstoreaccount1;"; + private const string TableEndpointTemplate = "TableEndpoint=http://127.0.0.1:{0}/devstoreaccount1;"; + + public static string Create(int? blobPort = null, int? queuePort = null, int? tablePort = null) + { + var builder = new StringBuilder(ConnectionStringHeader); + + if (blobPort is not null) + { + builder.AppendFormat(CultureInfo.InvariantCulture, BlobEndpointTemplate, blobPort); + } + if (queuePort is not null) + { + builder.AppendFormat(CultureInfo.InvariantCulture, QueueEndpointTemplate, queuePort); + } + if (tablePort is not null) + { + builder.AppendFormat(CultureInfo.InvariantCulture, TableEndpointTemplate, tablePort); + } + + return builder.ToString(); + } +} diff --git a/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs b/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs index 6bca9a4933..09fe2d345d 100644 --- a/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs +++ b/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Globalization; -using System.Text; using Aspire.Hosting.ApplicationModel; namespace Aspire.Hosting.Azure; @@ -52,32 +50,3 @@ internal ReferenceExpression GetBlobConnectionString() => IsEmulator ? ReferenceExpression.Create($"{AzureStorageEmulatorConnectionString.Create(blobPort: EmulatorBlobEndpoint.Port)}") : ReferenceExpression.Create($"{BlobEndpoint}"); } - -internal static class AzureStorageEmulatorConnectionString -{ - // Use defaults from https://learn.microsoft.com/azure/storage/common/storage-configure-connection-string#connect-to-the-emulator-account-using-the-shortcut - private const string ConnectionStringHeader = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;"; - private const string BlobEndpointTemplate = "BlobEndpoint=http://127.0.0.1:{0}/devstoreaccount1;"; - private const string QueueEndpointTemplate = "QueueEndpoint=http://127.0.0.1:{0}/devstoreaccount1;"; - private const string TableEndpointTemplate = "TableEndpoint=http://127.0.0.1:{0}/devstoreaccount1;"; - - public static string Create(int? blobPort = null, int? queuePort = null, int? tablePort = null) - { - var builder = new StringBuilder(ConnectionStringHeader); - - if (blobPort is not null) - { - builder.AppendFormat(CultureInfo.InvariantCulture, BlobEndpointTemplate, blobPort); - } - if (queuePort is not null) - { - builder.AppendFormat(CultureInfo.InvariantCulture, QueueEndpointTemplate, queuePort); - } - if (tablePort is not null) - { - builder.AppendFormat(CultureInfo.InvariantCulture, TableEndpointTemplate, tablePort); - } - - return builder.ToString(); - } -} diff --git a/src/Aspire.Hosting.Azure.WebPubSub/Aspire.Hosting.Azure.WebPubSub.csproj b/src/Aspire.Hosting.Azure.WebPubSub/Aspire.Hosting.Azure.WebPubSub.csproj index fa83120da6..85a9b16e57 100644 --- a/src/Aspire.Hosting.Azure.WebPubSub/Aspire.Hosting.Azure.WebPubSub.csproj +++ b/src/Aspire.Hosting.Azure.WebPubSub/Aspire.Hosting.Azure.WebPubSub.csproj @@ -32,8 +32,4 @@ - - - - diff --git a/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj b/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj index be7f63072e..e9c3d39719 100644 --- a/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj +++ b/src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj @@ -35,7 +35,7 @@ - + diff --git a/src/Aspire.Hosting.Azure/Exceptions.cs b/src/Aspire.Hosting.Azure/Exceptions.cs index b6518fbbb3..f77e4e419b 100644 --- a/src/Aspire.Hosting.Azure/Exceptions.cs +++ b/src/Aspire.Hosting.Azure/Exceptions.cs @@ -3,14 +3,14 @@ namespace Aspire.Hosting.Azure; -internal class AzureCliNotOnPathException : DistributedApplicationException +internal sealed class AzureCliNotOnPathException : DistributedApplicationException { public AzureCliNotOnPathException() { } public AzureCliNotOnPathException(string message) : base(message) { } public AzureCliNotOnPathException(string message, Exception inner) : base(message, inner) { } } -internal class FailedToApplyEnvironmentException : DistributedApplicationException +internal sealed class FailedToApplyEnvironmentException : DistributedApplicationException { public FailedToApplyEnvironmentException() { } public FailedToApplyEnvironmentException(string message) : base(message) { } diff --git a/tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj b/tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj new file mode 100644 index 0000000000..6fede690f8 --- /dev/null +++ b/tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj @@ -0,0 +1,31 @@ + + + + $(NetCurrent) + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Aspire.Hosting.Tests/Azure/AzureBicepProvisionerTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureBicepProvisionerTests.cs similarity index 97% rename from tests/Aspire.Hosting.Tests/Azure/AzureBicepProvisionerTests.cs rename to tests/Aspire.Hosting.Azure.Tests/AzureBicepProvisionerTests.cs index 0c4f5f8daa..3fb1204e1a 100644 --- a/tests/Aspire.Hosting.Tests/Azure/AzureBicepProvisionerTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureBicepProvisionerTests.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json.Nodes; -using Aspire.Hosting.Azure; +using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.Azure.Provisioning; using Aspire.Hosting.Utils; using Microsoft.Extensions.Configuration; using Xunit; -namespace Aspire.Hosting.Tests.Azure; +namespace Aspire.Hosting.Azure.Tests; public class AzureBicepProvisionerTests { @@ -32,10 +32,12 @@ public async Task SetParametersTranslatesCompatibleParameterTypes() { using var builder = TestDistributedApplicationBuilder.Create(); + builder.Configuration["Parameters:param"] = "paramValue"; + var connectionStringResource = builder.CreateResourceBuilder( new ResourceWithConnectionString("A", "connection string")); - var param = builder.AddParameter("param", _ => "paramValue"); + var param = builder.AddParameter("param"); var bicep0 = builder.AddBicepTemplateString("bicep0", "param name string") .WithParameter("name", "john") diff --git a/tests/Aspire.Hosting.Tests/Azure/AzureBicepResourceTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs similarity index 99% rename from tests/Aspire.Hosting.Tests/Azure/AzureBicepResourceTests.cs rename to tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs index 43bdd94c14..8fd69dd9a9 100644 --- a/tests/Aspire.Hosting.Tests/Azure/AzureBicepResourceTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs @@ -4,7 +4,7 @@ #pragma warning disable AZPROVISION001 // Because we are testing CDK callbacks. using System.Text.Json.Nodes; -using Aspire.Hosting.Azure; +using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.Lifecycle; using Aspire.Hosting.Tests.Utils; using Aspire.Hosting.Utils; @@ -19,7 +19,7 @@ using Xunit; using Xunit.Abstractions; -namespace Aspire.Hosting.Tests.Azure; +namespace Aspire.Hosting.Azure.Tests; public class AzureBicepResourceTests(ITestOutputHelper output) { @@ -732,7 +732,7 @@ public async Task WithReferenceAppInsightsSetsEnvironmentVariable() appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; - var serviceA = builder.AddProject("serviceA") + var serviceA = builder.AddProject("serviceA", o => o.ExcludeLaunchProfile = true) .WithReference(appInsights); var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(serviceA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); @@ -2707,7 +2707,7 @@ public async Task PublishAsConnectionString() var ai = builder.AddAzureApplicationInsights("ai").PublishAsConnectionString(); var serviceBus = builder.AddAzureServiceBus("servicebus").PublishAsConnectionString(); - var serviceA = builder.AddProject("serviceA") + var serviceA = builder.AddProject("serviceA", o => o.ExcludeLaunchProfile = true) .WithReference(ai) .WithReference(serviceBus); @@ -2923,7 +2923,5 @@ public async Task ConstructCanBeMutatedAfterCreation() private sealed class ProjectA : IProjectMetadata { public string ProjectPath => "projectA"; - - public LaunchSettings LaunchSettings { get; } = new(); } } diff --git a/tests/Aspire.Hosting.Tests/Azure/AzureEventHubsExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureEventHubsExtensionsTests.cs similarity index 98% rename from tests/Aspire.Hosting.Tests/Azure/AzureEventHubsExtensionsTests.cs rename to tests/Aspire.Hosting.Azure.Tests/AzureEventHubsExtensionsTests.cs index 7a6587f569..a31f02ec2b 100644 --- a/tests/Aspire.Hosting.Tests/Azure/AzureEventHubsExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureEventHubsExtensionsTests.cs @@ -4,8 +4,9 @@ using Aspire.Hosting.Utils; using Aspire.Hosting.Azure.EventHubs; using Xunit; +using Aspire.Hosting.ApplicationModel; -namespace Aspire.Hosting.Tests.Azure; +namespace Aspire.Hosting.Azure.Tests; public class AzureEventHubsExtensionsTests { diff --git a/tests/Aspire.Hosting.Tests/Azure/AzureResourceExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureResourceExtensionsTests.cs similarity index 98% rename from tests/Aspire.Hosting.Tests/Azure/AzureResourceExtensionsTests.cs rename to tests/Aspire.Hosting.Azure.Tests/AzureResourceExtensionsTests.cs index aac17dca3d..8967fd899e 100644 --- a/tests/Aspire.Hosting.Tests/Azure/AzureResourceExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureResourceExtensionsTests.cs @@ -1,10 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Aspire.Hosting.ApplicationModel; using Aspire.Hosting.Utils; using Xunit; -namespace Aspire.Hosting.Tests.Azure; +namespace Aspire.Hosting.Azure.Tests; public class AzureResourceExtensionsTests { diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureSchemaTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureSchemaTests.cs new file mode 100644 index 0000000000..f6787f3ba2 --- /dev/null +++ b/tests/Aspire.Hosting.Azure.Tests/AzureSchemaTests.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Aspire.Hosting.Tests.Schema; +using Xunit; + +namespace Aspire.Hosting.Azure.Tests; + +public class AzureSchemaTests +{ + [Fact] + public void ValidateApplicationSamples() + { + new SchemaTests().ValidateApplicationSamples("CdkResourceWithChildResource", (IDistributedApplicationBuilder builder) => + { + builder.AddPostgres("postgres").PublishAsAzurePostgresFlexibleServer().AddDatabase("db"); + }); + } +} diff --git a/tests/Aspire.Hosting.Tests/Azure/ResourceGroupNameHelpersTests.cs b/tests/Aspire.Hosting.Azure.Tests/ResourceGroupNameHelpersTests.cs similarity index 95% rename from tests/Aspire.Hosting.Tests/Azure/ResourceGroupNameHelpersTests.cs rename to tests/Aspire.Hosting.Azure.Tests/ResourceGroupNameHelpersTests.cs index 70a7a4dc63..ff34decd75 100644 --- a/tests/Aspire.Hosting.Tests/Azure/ResourceGroupNameHelpersTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/ResourceGroupNameHelpersTests.cs @@ -4,7 +4,7 @@ using Aspire.Hosting.Azure.Utils; using Xunit; -namespace Aspire.Hosting.Tests.Azure; +namespace Aspire.Hosting.Azure.Tests; public class ResourceGroupNameHelpersTests { diff --git a/tests/Aspire.Hosting.Tests.SharedShim/Aspire.Hosting.Tests.SharedShim.csproj b/tests/Aspire.Hosting.Tests.SharedShim/Aspire.Hosting.Tests.SharedShim.csproj deleted file mode 100644 index ccd1118d6a..0000000000 --- a/tests/Aspire.Hosting.Tests.SharedShim/Aspire.Hosting.Tests.SharedShim.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - $(NetCurrent) - enable - enable - - - - - - - - - - - - - - - diff --git a/tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj b/tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj index eff1af6a77..2048b53011 100644 --- a/tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj +++ b/tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj @@ -11,22 +11,6 @@ - - - - - - - - - - - - - - - - @@ -34,7 +18,6 @@ - @@ -51,7 +34,6 @@ - diff --git a/tests/Aspire.Hosting.Tests/Schema/SchemaTests.cs b/tests/Aspire.Hosting.Tests/Schema/SchemaTests.cs index bd05f8e07a..495970a33d 100644 --- a/tests/Aspire.Hosting.Tests/Schema/SchemaTests.cs +++ b/tests/Aspire.Hosting.Tests/Schema/SchemaTests.cs @@ -107,12 +107,6 @@ public static TheoryData> Applica } }, - { "CdkResourceWithChildResource", (IDistributedApplicationBuilder builder) => - { - builder.AddPostgres("postgres").PublishAsAzurePostgresFlexibleServer().AddDatabase("db"); - } - }, - { "BasicDockerfile", (IDistributedApplicationBuilder builder) => { builder.AddExecutable("foo", "bar", "baz", "one", "two", "three").PublishAsDockerFile(); diff --git a/tests/Aspire.Hosting.Tests/Utils/VolumeNameGeneratorTests.cs b/tests/Aspire.Hosting.Tests/Utils/VolumeNameGeneratorTests.cs index 840cd868a3..ca19a5014b 100644 --- a/tests/Aspire.Hosting.Tests/Utils/VolumeNameGeneratorTests.cs +++ b/tests/Aspire.Hosting.Tests/Utils/VolumeNameGeneratorTests.cs @@ -1,9 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -extern alias AspireHostingShared; - -using static AspireHostingShared::Aspire.Hosting.Utils.VolumeNameGenerator; +using static Aspire.Hosting.Utils.VolumeNameGenerator; using Xunit; namespace Aspire.Hosting.Tests.Utils;