-
Notifications
You must be signed in to change notification settings - Fork 854
Expand file tree
/
Copy pathTestModuleInitializer.cs
More file actions
38 lines (33 loc) · 1.52 KB
/
TestModuleInitializer.cs
File metadata and controls
38 lines (33 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Reflection;
using System.Runtime.CompilerServices;
using Aspire.TestUtilities;
namespace Aspire.Hosting.Azure.Tests;
sealed class TestModuleInitializer
{
[ModuleInitializer]
internal static void Setup()
{
// This file is compiled into multiple test assemblies. When test assemblies reference
// each other (e.g., Aspire.Cli.Tests references Aspire.Hosting.Tests), multiple module
// initializers may attempt to configure Verify. DerivePathInfo can only be called once
// before any Verify test runs. We use VerifyInitializer (in the shared Aspire.TestUtilities
// assembly) to ensure only the first caller configures it.
if (!VerifyInitializer.TryInitialize())
{
return;
}
DerivePathInfo(
(sourceFile, projectDirectory, type, method) => new(
directory: Path.Combine(
PlatformDetection.IsRunningOnHelix
? Path.GetDirectoryName(Assembly.GetExecutingAssembly()!.Location) ?? string.Empty
: projectDirectory,
"Snapshots"),
typeName: type.Name,
methodName: method.Name));
// auto-accept baseline changes when running locally
VerifierSettings.AutoVerify(includeBuildServer: false, throwException: true);
}
}