public async Task<Dictionary<string, string>> GetProcessEnvironment(TimeSpan timeout) { if (_useAsync) { using CancellationTokenSource cancellation = new CancellationTokenSource(timeout); return await _client.GetProcessEnvironmentAsync(cancellation.Token).ConfigureAwait(false); } else { return _client.GetProcessEnvironment(); } }
public void BasicEnvTest() { // as the attribute says, this test requires 5.0-rc1 or newer. This has been tested locally on // an rc1 build and passes. It is equivalent to the dotnet/runtime version of this test. TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(targetFramework: "net5.0"), output); string testKey = "FOO"; string testVal = "BAR"; runner.AddEnvVar(testKey, testVal); runner.Start(3000); DiagnosticsClient client = new DiagnosticsClient(runner.Pid); Dictionary <string, string> env = client.GetProcessEnvironment(); Assert.True(env.ContainsKey(testKey) && env[testKey].Equals(testVal)); runner.Stop(); }