From 004679f618878ea43e3fcedbf2ca28aae7b2025d Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 20 Jan 2026 15:43:55 +0100 Subject: [PATCH 1/4] Respect working directory of 'dotnet test' when determining results directory --- .../Builder/TestApplication.cs | 4 +++- .../Configurations/AggregatedConfiguration.cs | 4 +++- .../Configurations/ConfigurationManager.cs | 5 +++-- .../Helpers/EnvironmentVariableConstants.cs | 1 + .../Hosts/TestHostBuilder.cs | 2 +- .../Adapter_ExecuteRequestAsyncTests.cs | 2 +- .../AggregatedConfigurationTests.cs | 16 ++++++++-------- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs b/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs index c43941a379..1f00df5d19 100644 --- a/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs +++ b/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs @@ -310,7 +310,9 @@ private static ApplicationLoggingState CreateFileLoggerIfDiagnosticIsEnabled( } // Set the directory to the default test result directory - string directory = Path.Combine(testApplicationModuleInfo.GetCurrentTestApplicationDirectory(), AggregatedConfiguration.DefaultTestResultFolderName); + string? effectiveWorkingDirectory = environment.GetEnvironmentVariable(EnvironmentVariableConstants.DOTNET_CLI_TEST_COMMAND_WORKING_DIRECTORY); + effectiveWorkingDirectory ??= testApplicationModuleInfo.GetCurrentTestApplicationDirectory(); + string directory = Path.Combine(effectiveWorkingDirectory, AggregatedConfiguration.DefaultTestResultFolderName); bool customDirectory = false; if (result.TryGetOptionArgumentList(PlatformCommandLineProvider.ResultDirectoryOptionKey, out string[]? resultDirectoryArg)) diff --git a/src/Platform/Microsoft.Testing.Platform/Configurations/AggregatedConfiguration.cs b/src/Platform/Microsoft.Testing.Platform/Configurations/AggregatedConfiguration.cs index ba1f697d5e..315af1d3e2 100644 --- a/src/Platform/Microsoft.Testing.Platform/Configurations/AggregatedConfiguration.cs +++ b/src/Platform/Microsoft.Testing.Platform/Configurations/AggregatedConfiguration.cs @@ -12,12 +12,14 @@ internal sealed class AggregatedConfiguration( IConfigurationProvider[] configurationProviders, ITestApplicationModuleInfo testApplicationModuleInfo, IFileSystem fileSystem, + IEnvironment environment, CommandLineParseResult commandLineParseResult) : IConfiguration { public const string DefaultTestResultFolderName = "TestResults"; private readonly IConfigurationProvider[] _configurationProviders = configurationProviders; private readonly ITestApplicationModuleInfo _testApplicationModuleInfo = testApplicationModuleInfo; private readonly IFileSystem _fileSystem = fileSystem; + private readonly IEnvironment _environment = environment; private readonly CommandLineParseResult _commandLineParseResult = commandLineParseResult; private string? _resultsDirectory; private string? _currentWorkingDirectory; @@ -94,7 +96,7 @@ private string GetResultsDirectoryCore(CommandLineParseResult commandLineParseRe // If not specified by command line, then use the configuration providers. // And finally fallback to DefaultTestResultFolderName relative to the current working directory. return CalculateFromConfigurationProviders(PlatformConfigurationConstants.PlatformResultDirectory) - ?? Path.Combine(this[PlatformConfigurationConstants.PlatformCurrentWorkingDirectory]!, DefaultTestResultFolderName); + ?? Path.Combine(_environment.GetEnvironmentVariable(EnvironmentVariableConstants.DOTNET_CLI_TEST_COMMAND_WORKING_DIRECTORY) ?? this[PlatformConfigurationConstants.PlatformCurrentWorkingDirectory]!, DefaultTestResultFolderName); } private string GetCurrentWorkingDirectoryCore() diff --git a/src/Platform/Microsoft.Testing.Platform/Configurations/ConfigurationManager.cs b/src/Platform/Microsoft.Testing.Platform/Configurations/ConfigurationManager.cs index bf9b7a51e6..58bd22777f 100644 --- a/src/Platform/Microsoft.Testing.Platform/Configurations/ConfigurationManager.cs +++ b/src/Platform/Microsoft.Testing.Platform/Configurations/ConfigurationManager.cs @@ -12,11 +12,12 @@ namespace Microsoft.Testing.Platform.Configurations; -internal sealed class ConfigurationManager(IFileSystem fileSystem, ITestApplicationModuleInfo testApplicationModuleInfo) : IConfigurationManager +internal sealed class ConfigurationManager(IFileSystem fileSystem, ITestApplicationModuleInfo testApplicationModuleInfo, IEnvironment environment) : IConfigurationManager { private readonly List> _configurationSources = []; private readonly IFileSystem _fileSystem = fileSystem; private readonly ITestApplicationModuleInfo _testApplicationModuleInfo = testApplicationModuleInfo; + private readonly IEnvironment _environment = environment; public void AddConfigurationSource(Func source) => _configurationSources.Add(source); @@ -58,6 +59,6 @@ internal async Task BuildAsync(IFileLoggerProvider? syncFileLogg return defaultJsonConfiguration is null ? throw new InvalidOperationException(PlatformResources.ConfigurationManagerCannotFindDefaultJsonConfigurationErrorMessage) - : new AggregatedConfiguration([.. configurationProviders.OrderBy(x => x.Order).Select(x => x.ConfigurationProvider)], _testApplicationModuleInfo, _fileSystem, commandLineParseResult); + : new AggregatedConfiguration([.. configurationProviders.OrderBy(x => x.Order).Select(x => x.ConfigurationProvider)], _testApplicationModuleInfo, _fileSystem, _environment, commandLineParseResult); } } diff --git a/src/Platform/Microsoft.Testing.Platform/Helpers/EnvironmentVariableConstants.cs b/src/Platform/Microsoft.Testing.Platform/Helpers/EnvironmentVariableConstants.cs index e496cbc3af..4cecf803a3 100644 --- a/src/Platform/Microsoft.Testing.Platform/Helpers/EnvironmentVariableConstants.cs +++ b/src/Platform/Microsoft.Testing.Platform/Helpers/EnvironmentVariableConstants.cs @@ -36,6 +36,7 @@ internal static class EnvironmentVariableConstants // dotnet test public const string TESTINGPLATFORM_DOTNETTEST_EXECUTIONID = nameof(TESTINGPLATFORM_DOTNETTEST_EXECUTIONID); + public const string DOTNET_CLI_TEST_COMMAND_WORKING_DIRECTORY = nameof(DOTNET_CLI_TEST_COMMAND_WORKING_DIRECTORY); // Unhandled Exception public const string TESTINGPLATFORM_EXIT_PROCESS_ON_UNHANDLED_EXCEPTION = nameof(TESTINGPLATFORM_EXIT_PROCESS_ON_UNHANDLED_EXCEPTION); diff --git a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs index beb17eeeea..227f07a355 100644 --- a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs +++ b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs @@ -43,7 +43,7 @@ internal sealed class TestHostBuilder(IFileSystem fileSystem, IRuntimeFeature ru public ITestHostManager TestHost { get; } = new TestHostManager(); - public IConfigurationManager Configuration { get; } = new ConfigurationManager(fileSystem, testApplicationModuleInfo); + public IConfigurationManager Configuration { get; } = new ConfigurationManager(fileSystem, testApplicationModuleInfo, environment); public ILoggingManager Logging { get; } = new LoggingManager(); diff --git a/test/UnitTests/MSTest.Engine.UnitTests/Adapter_ExecuteRequestAsyncTests.cs b/test/UnitTests/MSTest.Engine.UnitTests/Adapter_ExecuteRequestAsyncTests.cs index efd47c4bf9..00f5d71825 100644 --- a/test/UnitTests/MSTest.Engine.UnitTests/Adapter_ExecuteRequestAsyncTests.cs +++ b/test/UnitTests/MSTest.Engine.UnitTests/Adapter_ExecuteRequestAsyncTests.cs @@ -109,7 +109,7 @@ public Services() ServiceProvider.AddService(new LoggerFactory()); ServiceProvider.AddService(new FakeClock()); ServiceProvider.AddService(new SystemTask()); - ServiceProvider.AddService(new AggregatedConfiguration([], new CurrentTestApplicationModuleInfo(new SystemEnvironment(), new SystemProcessHandler()), new SystemFileSystem(), new(null, [], []))); + ServiceProvider.AddService(new AggregatedConfiguration([], new CurrentTestApplicationModuleInfo(new SystemEnvironment(), new SystemProcessHandler()), new SystemFileSystem(), new SystemEnvironment(), new(null, [], []))); } public MessageBus MessageBus { get; } diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/AggregatedConfigurationTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/AggregatedConfigurationTests.cs index 284dd62341..a07b34082e 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/AggregatedConfigurationTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/AggregatedConfigurationTests.cs @@ -33,7 +33,7 @@ public void IndexerTest_DirectoryNotSetAndNoConfigurationProviders(string key) _ => throw ApplicationStateGuard.Unreachable(), }; - Assert.AreEqual(expected, new AggregatedConfiguration([], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new(null, [], []))[key]); + Assert.AreEqual(expected, new AggregatedConfiguration([], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new SystemEnvironment(), new(null, [], []))[key]); } [TestMethod] @@ -43,7 +43,7 @@ public void IndexerTest_DirectoryNotSetButConfigurationProvidersPresent_Director { Mock mockProvider = new(); - AggregatedConfiguration aggregatedConfiguration = new([mockProvider.Object], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new(null, [], [])); + AggregatedConfiguration aggregatedConfiguration = new([mockProvider.Object], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new SystemEnvironment(), new(null, [], [])); Assert.IsNull(aggregatedConfiguration[key]); } @@ -53,21 +53,21 @@ public void IndexerTest_DirectoryNotSetButConfigurationProvidersPresent_Director [DataRow(PlatformConfigurationConstants.PlatformTestHostWorkingDirectory)] public void IndexerTest_DirectoryNotSetButConfigurationProvidersPresent_DirectoryIsNotNull(string key) { - AggregatedConfiguration aggregatedConfiguration = new([new FakeConfigurationProvider(ExpectedPath)], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new(null, [], [])); + AggregatedConfiguration aggregatedConfiguration = new([new FakeConfigurationProvider(ExpectedPath)], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new SystemEnvironment(), new(null, [], [])); Assert.AreEqual(ExpectedPath, aggregatedConfiguration[key]); } [TestMethod] public void IndexerTest_ResultDirectorySet_DirectoryIsNotNull() { - AggregatedConfiguration aggregatedConfiguration = new([], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new(null, [new CommandLineParseOption("results-directory", [ExpectedPath])], [])); + AggregatedConfiguration aggregatedConfiguration = new([], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new SystemEnvironment(), new(null, [new CommandLineParseOption("results-directory", [ExpectedPath])], [])); Assert.AreEqual(ExpectedPath, aggregatedConfiguration[PlatformConfigurationConstants.PlatformResultDirectory]); } [TestMethod] public void IndexerTest_CurrentWorkingDirectorySet_DirectoryIsNotNull() { - AggregatedConfiguration aggregatedConfiguration = new([], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new(null, [], [])); + AggregatedConfiguration aggregatedConfiguration = new([], _testApplicationModuleInfoMock.Object, _fileSystemMock.Object, new SystemEnvironment(), new(null, [], [])); aggregatedConfiguration.SetCurrentWorkingDirectory(ExpectedPath); Assert.AreEqual(ExpectedPath, aggregatedConfiguration[PlatformConfigurationConstants.PlatformCurrentWorkingDirectory]); @@ -86,7 +86,7 @@ public async ValueTask CheckTestResultsDirectoryOverrideAndCreateItAsync_Results Mock mockFileLogger = new(); mockFileLogger.Setup(x => x.CheckLogFolderAndMoveToTheNewIfNeededAsync(It.IsAny())).Callback(() => { }); - AggregatedConfiguration aggregatedConfiguration = new([], mockTestApplicationModuleInfo.Object, mockFileSystem.Object, new(null, [new CommandLineParseOption("results-directory", [ExpectedPath])], [])); + AggregatedConfiguration aggregatedConfiguration = new([], mockTestApplicationModuleInfo.Object, mockFileSystem.Object, new SystemEnvironment(), new(null, [new CommandLineParseOption("results-directory", [ExpectedPath])], [])); await aggregatedConfiguration.CheckTestResultsDirectoryOverrideAndCreateItAsync(mockFileLogger.Object); mockFileSystem.Verify(x => x.CreateDirectory(ExpectedPath), Times.Once); @@ -108,7 +108,7 @@ public async ValueTask CheckTestResultsDirectoryOverrideAndCreateItAsync_Results Mock mockFileLogger = new(); mockFileLogger.Setup(x => x.CheckLogFolderAndMoveToTheNewIfNeededAsync(It.IsAny())).Callback(() => { }); - AggregatedConfiguration aggregatedConfiguration = new([], mockTestApplicationModuleInfo.Object, mockFileSystem.Object, new(null, [new CommandLineParseOption("results-directory", [ExpectedPath])], [])); + AggregatedConfiguration aggregatedConfiguration = new([], mockTestApplicationModuleInfo.Object, mockFileSystem.Object, new SystemEnvironment(), new(null, [new CommandLineParseOption("results-directory", [ExpectedPath])], [])); await aggregatedConfiguration.CheckTestResultsDirectoryOverrideAndCreateItAsync(mockFileLogger.Object); mockFileSystem.Verify(x => x.CreateDirectory(ExpectedPath), Times.Once); @@ -130,7 +130,7 @@ public async ValueTask CheckTestResultsDirectoryOverrideAndCreateItAsync_Results Mock mockFileLogger = new(); mockFileLogger.Setup(x => x.CheckLogFolderAndMoveToTheNewIfNeededAsync(It.IsAny())).Callback(() => { }); - AggregatedConfiguration aggregatedConfiguration = new([], mockTestApplicationModuleInfo.Object, mockFileSystem.Object, new(null, [], [])); + AggregatedConfiguration aggregatedConfiguration = new([], mockTestApplicationModuleInfo.Object, mockFileSystem.Object, new SystemEnvironment(), new(null, [], [])); await aggregatedConfiguration.CheckTestResultsDirectoryOverrideAndCreateItAsync(mockFileLogger.Object); string expectedPath = "a" + Path.DirectorySeparatorChar + "b" + Path.DirectorySeparatorChar + "TestResults"; From d76e16cd4bef38e049107e15e587639c4982869d Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 20 Jan 2026 15:53:13 +0100 Subject: [PATCH 2/4] Cleanup dead code --- .../Services/CurrentTestApplicationModuleInfo.cs | 2 +- .../Microsoft.Testing.Platform/Services/ExecutableInfo.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs b/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs index ebd46b602a..0da6703115 100644 --- a/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs +++ b/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs @@ -127,6 +127,6 @@ public ExecutableInfo GetCurrentExecutableInfo() _ => commandLineArguments, }; - return new(GetProcessPath(), arguments, GetCurrentTestApplicationDirectory()); + return new ExecutableInfo(GetProcessPath(), arguments); } } diff --git a/src/Platform/Microsoft.Testing.Platform/Services/ExecutableInfo.cs b/src/Platform/Microsoft.Testing.Platform/Services/ExecutableInfo.cs index 17b6023e2b..b638041eb1 100644 --- a/src/Platform/Microsoft.Testing.Platform/Services/ExecutableInfo.cs +++ b/src/Platform/Microsoft.Testing.Platform/Services/ExecutableInfo.cs @@ -3,14 +3,12 @@ namespace Microsoft.Testing.Platform.Services; -internal sealed class ExecutableInfo(string filePath, IEnumerable arguments, string workspace) +internal sealed class ExecutableInfo(string filePath, IEnumerable arguments) { public string FilePath { get; } = filePath; public IEnumerable Arguments { get; } = arguments; - public string Workspace { get; } = workspace; - public override string ToString() - => $"Process: {FilePath}, Arguments: {string.Join(' ', Arguments)}, Workspace: {Workspace}"; + => $"Process: {FilePath}, Arguments: {string.Join(' ', Arguments)}"; } From 5fd14ec41bdfd1ff34216a63914f0e504adc2157 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 20 Jan 2026 15:55:28 +0100 Subject: [PATCH 3/4] Delete dead code --- .../Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs | 5 ----- .../TestHostControllers/TestHostControllersManager.cs | 8 -------- 2 files changed, 13 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs index 227f07a355..a9787c3f6a 100644 --- a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs +++ b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs @@ -481,11 +481,6 @@ await LogTestHostCreatedAsync( policiesService.ProcessRole = TestProcessRole.TestHost; await proxyOutputDevice.HandleProcessRoleAsync(TestProcessRole.TestHost, testApplicationCancellationTokenSource.CancellationToken).ConfigureAwait(false); - // Setup the test host working folder. - // Out of the test host controller extension the current working directory is the test host working directory. - string? currentWorkingDirectory = configuration[PlatformConfigurationConstants.PlatformCurrentWorkingDirectory]; - ApplicationStateGuard.Ensure(currentWorkingDirectory is not null); - testHostControllerInfo.IsCurrentProcessTestHostController = false; // If we're under test controllers and currently we're inside the started test host we connect to the out of process diff --git a/src/Platform/Microsoft.Testing.Platform/TestHostControllers/TestHostControllersManager.cs b/src/Platform/Microsoft.Testing.Platform/TestHostControllers/TestHostControllersManager.cs index a597b3aba9..77d9c3d213 100644 --- a/src/Platform/Microsoft.Testing.Platform/TestHostControllers/TestHostControllersManager.cs +++ b/src/Platform/Microsoft.Testing.Platform/TestHostControllers/TestHostControllersManager.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using Microsoft.Testing.Platform.Configurations; using Microsoft.Testing.Platform.Extensions; using Microsoft.Testing.Platform.Extensions.TestHostControllers; using Microsoft.Testing.Platform.Helpers; @@ -108,13 +107,6 @@ public void AddDataConsumer(CompositeExtensionFactory compositeServiceFact internal async Task BuildAsync(ServiceProvider serviceProvider) { - // For now the test host working directory and the current working directory are the same. - // In future we could move the test host in a different directory for instance in case of - // the need to rewrite binary files. If we don't move files are locked by ourself. - var aggregatedConfiguration = (AggregatedConfiguration)serviceProvider.GetConfiguration(); - string? currentWorkingDirectory = aggregatedConfiguration[PlatformConfigurationConstants.PlatformCurrentWorkingDirectory]; - ApplicationStateGuard.Ensure(currentWorkingDirectory is not null); - List<(ITestHostEnvironmentVariableProvider TestHostEnvironmentVariableProvider, int RegistrationOrder)> environmentVariableProviders = []; foreach (Func environmentVariableProviderFactory in _environmentVariableProviderFactories) { From 26cf7e36c9c4cacbfbc886d83012b8719fd939a5 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Tue, 20 Jan 2026 16:36:41 +0100 Subject: [PATCH 4/4] Fix build --- .../Configuration/ConfigurationManagerTests.cs | 12 ++++++------ .../TestApplicationBuilderTests.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/ConfigurationManagerTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/ConfigurationManagerTests.cs index 063e9b5116..6304368516 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/ConfigurationManagerTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/ConfigurationManagerTests.cs @@ -27,7 +27,7 @@ public async ValueTask GetConfigurationValueFromJson(string jsonFileConfig, stri fileSystem.Setup(x => x.NewFileStream(It.IsAny(), FileMode.Open, FileAccess.Read)) .Returns(new MemoryFileStream(Encoding.UTF8.GetBytes(jsonFileConfig))); CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(new SystemEnvironment(), new SystemProcessHandler()); - ConfigurationManager configurationManager = new(fileSystem.Object, testApplicationModuleInfo); + ConfigurationManager configurationManager = new(fileSystem.Object, testApplicationModuleInfo, new SystemEnvironment()); configurationManager.AddConfigurationSource(() => new JsonConfigurationSource(testApplicationModuleInfo, fileSystem.Object, null)); IConfiguration configuration = await configurationManager.BuildAsync(null, new CommandLineParseResult(null, new List(), [])); Assert.AreEqual(result, configuration[key], $"Expected '{result}' found '{configuration[key]}'"); @@ -57,7 +57,7 @@ public async ValueTask InvalidJson_Fail() fileSystem.Setup(x => x.ExistFile(It.IsAny())).Returns(true); fileSystem.Setup(x => x.NewFileStream(It.IsAny(), FileMode.Open, FileAccess.Read)).Returns(() => new MemoryFileStream(Encoding.UTF8.GetBytes(string.Empty))); CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(new SystemEnvironment(), new SystemProcessHandler()); - ConfigurationManager configurationManager = new(fileSystem.Object, testApplicationModuleInfo); + ConfigurationManager configurationManager = new(fileSystem.Object, testApplicationModuleInfo, new SystemEnvironment()); configurationManager.AddConfigurationSource(() => new JsonConfigurationSource(testApplicationModuleInfo, fileSystem.Object, null)); @@ -87,7 +87,7 @@ public async ValueTask GetConfigurationValueFromJsonWithFileLoggerProvider(strin loggerProviderMock.Setup(x => x.CreateLogger(It.IsAny())).Returns(loggerMock.Object); CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(new SystemEnvironment(), new SystemProcessHandler()); - ConfigurationManager configurationManager = new(fileSystem.Object, testApplicationModuleInfo); + ConfigurationManager configurationManager = new(fileSystem.Object, testApplicationModuleInfo, new SystemEnvironment()); configurationManager.AddConfigurationSource(() => new JsonConfigurationSource(testApplicationModuleInfo, fileSystem.Object, null)); @@ -101,7 +101,7 @@ public async ValueTask GetConfigurationValueFromJsonWithFileLoggerProvider(strin public async ValueTask BuildAsync_EmptyConfigurationSources_ThrowsException() { CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(new SystemEnvironment(), new SystemProcessHandler()); - ConfigurationManager configurationManager = new(new SystemFileSystem(), testApplicationModuleInfo); + ConfigurationManager configurationManager = new(new SystemFileSystem(), testApplicationModuleInfo, new SystemEnvironment()); await Assert.ThrowsAsync(() => configurationManager.BuildAsync(null, new CommandLineParseResult(null, new List(), []))); } @@ -112,7 +112,7 @@ public async ValueTask BuildAsync_ConfigurationSourcesNotEnabledAsync_ThrowsExce mockConfigurationSource.Setup(x => x.IsEnabledAsync()).ReturnsAsync(false); CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(new SystemEnvironment(), new SystemProcessHandler()); - ConfigurationManager configurationManager = new(new SystemFileSystem(), testApplicationModuleInfo); + ConfigurationManager configurationManager = new(new SystemFileSystem(), testApplicationModuleInfo, new SystemEnvironment()); configurationManager.AddConfigurationSource(() => mockConfigurationSource.Object); await Assert.ThrowsAsync(() => configurationManager.BuildAsync(null, new CommandLineParseResult(null, new List(), []))); @@ -132,7 +132,7 @@ public async ValueTask BuildAsync_ConfigurationSourceIsAsyncInitializableExtensi }; CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(new SystemEnvironment(), new SystemProcessHandler()); - ConfigurationManager configurationManager = new(new SystemFileSystem(), testApplicationModuleInfo); + ConfigurationManager configurationManager = new(new SystemFileSystem(), testApplicationModuleInfo, new SystemEnvironment()); configurationManager.AddConfigurationSource(() => fakeConfigurationSource); await Assert.ThrowsAsync(() => configurationManager.BuildAsync(null, new CommandLineParseResult(null, new List(), []))); diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/TestApplicationBuilderTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/TestApplicationBuilderTests.cs index c900654889..18ae50fd08 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/TestApplicationBuilderTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/TestApplicationBuilderTests.cs @@ -21,7 +21,7 @@ public sealed class TestApplicationBuilderTests public TestApplicationBuilderTests() { CurrentTestApplicationModuleInfo testApplicationModuleInfo = new(new SystemEnvironment(), new SystemProcessHandler()); - AggregatedConfiguration configuration = new([], testApplicationModuleInfo, new SystemFileSystem(), new(null, [], [])); + AggregatedConfiguration configuration = new([], testApplicationModuleInfo, new SystemFileSystem(), new SystemEnvironment(), new(null, [], [])); configuration.SetCurrentWorkingDirectory(string.Empty); configuration.SetCurrentWorkingDirectory(string.Empty); _serviceProvider.AddService(configuration);