Alvecta.Foundation.Deployment.Cdk.Testing
9.0.84
See the version list below for details.
dotnet add package Alvecta.Foundation.Deployment.Cdk.Testing --version 9.0.84
NuGet\Install-Package Alvecta.Foundation.Deployment.Cdk.Testing -Version 9.0.84
<PackageReference Include="Alvecta.Foundation.Deployment.Cdk.Testing" Version="9.0.84" />
<PackageVersion Include="Alvecta.Foundation.Deployment.Cdk.Testing" Version="9.0.84" />
<PackageReference Include="Alvecta.Foundation.Deployment.Cdk.Testing" />
paket add Alvecta.Foundation.Deployment.Cdk.Testing --version 9.0.84
#r "nuget: Alvecta.Foundation.Deployment.Cdk.Testing, 9.0.84"
#:package Alvecta.Foundation.Deployment.Cdk.Testing@9.0.84
#addin nuget:?package=Alvecta.Foundation.Deployment.Cdk.Testing&version=9.0.84
#tool nuget:?package=Alvecta.Foundation.Deployment.Cdk.Testing&version=9.0.84
Alvecta.Foundation.Deployment.Cdk.Testing
Test support for the deployment tests of a solution whose CDK apps are built on
Alvecta.Foundation.Deployment.Cdk.
Reference it from a test project only; the Alvecta architecture tests fail a product project that
references a *.Testing package.
What it provides
CdkJsonFile reads the repository's cdk.json - the one configuration the solution's CDK apps
share - the way the Foundation hosts read it, so the tests run against the real environments rather
than a fixture:
FindDirectory()— the nearest folder above the test output that holdscdk.json, the repository root in an Alvecta solution. Other repository files are read relative to it.GetEnvironments(),GetEnvironment(environment),GetService(environment, service)— thecontext.Environments,context.Environments.<environment>andcontext.Environments.<environment>.Services.<service>sections, through the sameCdkContextExtensions.GetSectionthe hosts navigate with, so a missing section fails naming it.EnvironmentsandConfiguredEnvironments— every environment of the file, and those whose AWS account is filled in, as xunitTheoryData<string>. A placeholder environment (an empty account) can be loaded and validated but not synthesized: CDK refuses an environment without an account.CreateApp(environment)— a CDK app with the context the hosts read: the environment asenvand theEnvironmentssection exactly ascdk.jsonholds it.
The file is read anew on every call.
Usage
[Collection(nameof(CdkAppCollection))]
public class CdkJsonDatabaseStackTests
{
[Theory]
[MemberData(nameof(CdkJsonFile.Environments), MemberType = typeof(CdkJsonFile))]
public void Environment_ShouldLoadIntoTheEnvironmentConfig(string environment)
{
var config = SettingsLoader.Load<EnvironmentConfig>(CdkJsonFile.GetEnvironment(environment));
Assert.NotEmpty(config.SsmParameterPrefix);
}
[Theory]
[MemberData(nameof(CdkJsonFile.ConfiguredEnvironments), MemberType = typeof(CdkJsonFile))]
public void DatabaseStack_ShouldSynthesize(string environment)
{
var app = CdkJsonFile.CreateApp(environment);
// ... build the stack from app, then Template.FromStack(stack)
}
}
JSII, the CDK's runtime bridge, is not safe to drive from several test threads at once, so the tests that create apps share a collection with parallelization disabled. xunit only reads collection definitions from the test assembly itself, so each test project declares its own:
[CollectionDefinition(nameof(CdkAppCollection), DisableParallelization = true)]
public class CdkAppCollection;
The walk up from the test output needs the output inside the repository (the default bin/ layout).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Alvecta.Foundation.Deployment.Cdk (>= 9.0.84)
- Alvecta.Utils (>= 8.4.80)
- Amazon.CDK.Lib (>= 2.275.0)
- Constructs (>= 10.8.1)
- xunit.v3.extensibility.core (>= 4.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.