Make StartupTests.Ctor_LoadsManagedAssembly more accurate (#877)

* Refactor Startup

* Fix

Co-authored-by: Rajkumar Rangaraj <rajrang@microsoft.com>
This commit is contained in:
Robert Pająk 2022-06-23 17:19:14 +02:00 committed by GitHub
parent 215ab65b33
commit 07d5e80cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -25,6 +25,8 @@ namespace OpenTelemetry.AutoInstrumentation.Loader;
/// </summary>
public partial class Startup
{
private static readonly string ManagedProfilerDirectory;
/// <summary>
/// Initializes static members of the <see cref="Startup"/> class.
/// This method also attempts to load the OpenTelemetry.AutoInstrumentation .NET assembly.
@ -45,8 +47,6 @@ public partial class Startup
TryLoadManagedAssembly();
}
internal static string ManagedProfilerDirectory { get; }
private static void TryLoadManagedAssembly()
{
StartupLogger.Log("Managed Loader TryLoadManagedAssembly()");

View File

@ -29,7 +29,7 @@ public class StartupTests
var directory = Directory.GetCurrentDirectory();
Environment.SetEnvironmentVariable("OTEL_DOTNET_AUTO_HOME", Path.Combine(directory, "..", "Profiler"));
var exception = Record.Exception(() => AutoInstrumentation.Loader.Startup.ManagedProfilerDirectory);
var exception = Record.Exception(() => new AutoInstrumentation.Loader.Startup());
// That means the assembly was loaded successfully and Initialize method was called.
Assert.Null(exception);