Fix IDE0090 (#2211)

This commit is contained in:
Cory Miller
2022-10-18 10:54:08 -04:00
committed by GitHub
parent daba735b52
commit b87b4aac5c
99 changed files with 412 additions and 412 deletions

View File

@@ -15,7 +15,7 @@ namespace GitHub.Runner.Common.Tests
{
Tracing trace = hc.GetTrace();
CommandLineParser clp = new CommandLineParser(hc, secretArgNames: new string[0]);
CommandLineParser clp = new(hc, secretArgNames: new string[0]);
trace.Info("Constructed");
Assert.NotNull(clp);
@@ -30,7 +30,7 @@ namespace GitHub.Runner.Common.Tests
using (TestHostContext hc = CreateTestContext())
{
// Arrange.
CommandLineParser clp = new CommandLineParser(
CommandLineParser clp = new(
hc,
secretArgNames: new[] { "SecretArg1", "SecretArg2" });
@@ -61,7 +61,7 @@ namespace GitHub.Runner.Common.Tests
{
Tracing trace = hc.GetTrace();
CommandLineParser clp = new CommandLineParser(hc, secretArgNames: new string[0]);
CommandLineParser clp = new(hc, secretArgNames: new string[0]);
trace.Info("Constructed.");
clp.Parse(new string[] { "cmd1", "cmd2", "--arg1", "arg1val", "badcmd" });
@@ -81,7 +81,7 @@ namespace GitHub.Runner.Common.Tests
{
Tracing trace = hc.GetTrace();
CommandLineParser clp = new CommandLineParser(hc, secretArgNames: new string[0]);
CommandLineParser clp = new(hc, secretArgNames: new string[0]);
trace.Info("Constructed.");
clp.Parse(new string[] { "cmd1", "--arg1", "arg1val", "--arg2", "arg2val" });
@@ -105,7 +105,7 @@ namespace GitHub.Runner.Common.Tests
{
Tracing trace = hc.GetTrace();
CommandLineParser clp = new CommandLineParser(hc, secretArgNames: new string[0]);
CommandLineParser clp = new(hc, secretArgNames: new string[0]);
trace.Info("Constructed.");
clp.Parse(new string[] { "cmd1", "--flag1", "--arg1", "arg1val", "--flag2" });
@@ -120,7 +120,7 @@ namespace GitHub.Runner.Common.Tests
private TestHostContext CreateTestContext([CallerMemberName] string testName = "")
{
TestHostContext hc = new TestHostContext(this, testName);
TestHostContext hc = new(this, testName);
return hc;
}
}

View File

@@ -12,7 +12,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Runner")]
public void BuildConstantGenerateSucceed()
{
List<string> validPackageNames = new List<string>()
List<string> validPackageNames = new()
{
"win-x64",
"win-x86",

View File

@@ -12,10 +12,10 @@ namespace GitHub.Runner.Common.Tests.Worker.Container
public void MountVolumeConstructorParsesStringInput()
{
// Arrange
MountVolume target = new MountVolume("/dst/dir"); // Maps anonymous Docker volume into target dir
MountVolume source_target = new MountVolume("/src/dir:/dst/dir"); // Maps source to target dir
MountVolume target_ro = new MountVolume("/dst/dir:ro");
MountVolume source_target_ro = new MountVolume("/src/dir:/dst/dir:ro");
MountVolume target = new("/dst/dir"); // Maps anonymous Docker volume into target dir
MountVolume source_target = new("/src/dir:/dst/dir"); // Maps source to target dir
MountVolume target_ro = new("/dst/dir:ro");
MountVolume source_target_ro = new("/src/dir:/dst/dir:ro");
// Assert
Assert.Null(target.SourceVolumePath);

View File

@@ -21,7 +21,7 @@ namespace GitHub.Runner.Common.Tests
string shDownloadUrl = "https://dot.net/v1/dotnet-install.sh";
using (HttpClient downloadClient = new HttpClient())
using (HttpClient downloadClient = new())
{
var response = await downloadClient.GetAsync("https://www.bing.com");
if (!response.IsSuccessStatusCode)
@@ -51,7 +51,7 @@ namespace GitHub.Runner.Common.Tests
string ps1DownloadUrl = "https://dot.net/v1/dotnet-install.ps1";
using (HttpClient downloadClient = new HttpClient())
using (HttpClient downloadClient = new())
{
var response = await downloadClient.GetAsync("https://www.bing.com");
if (!response.IsSuccessStatusCode)

View File

@@ -13,7 +13,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public void LoadsTypeFromString()
{
using (TestHostContext tc = new TestHostContext(this))
using (TestHostContext tc = new(this))
{
// Arrange.
var manager = new ExtensionManager();
@@ -34,7 +34,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public void LoadsTypes()
{
using (TestHostContext tc = new TestHostContext(this))
using (TestHostContext tc = new(this))
{
// Arrange.
var manager = new ExtensionManager();

View File

@@ -9,7 +9,7 @@ namespace GitHub.Runner.Common.Tests
{
public sealed class CommandSettingsL0
{
private readonly Mock<IPromptManager> _promptManager = new Mock<IPromptManager>();
private readonly Mock<IPromptManager> _promptManager = new();
// It is sufficient to test one arg only. All individual args are tested by the PromptsFor___ methods.
// The PromptsFor___ methods suffice to cover the interesting differences between each of the args.
@@ -879,7 +879,7 @@ namespace GitHub.Runner.Common.Tests
private TestHostContext CreateTestContext([CallerMemberName] string testName = "")
{
TestHostContext hc = new TestHostContext(this, testName);
TestHostContext hc = new(this, testName);
hc.SetSingleton<IPromptManager>(_promptManager.Object);
return hc;
}

View File

@@ -10,7 +10,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "ArgumentValidator")]
public void ServerUrlValidator()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Assert.True(Validators.ServerUrlValidator("http://servername"));
Assert.False(Validators.ServerUrlValidator("Fail"));
@@ -23,7 +23,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "ArgumentValidator")]
public void AuthSchemeValidator()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Assert.True(Validators.AuthSchemeValidator("OAuth"));
Assert.False(Validators.AuthSchemeValidator("Fail"));
@@ -35,7 +35,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "ArgumentValidator")]
public void NonEmptyValidator()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Assert.True(Validators.NonEmptyValidator("test"));
Assert.False(Validators.NonEmptyValidator(string.Empty));

View File

@@ -44,7 +44,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
private int _defaultRunnerGroupId = 1;
private int _secondRunnerGroupId = 2;
private RSACryptoServiceProvider rsa = null;
private RunnerSettings _configMgrAgentSettings = new RunnerSettings();
private RunnerSettings _configMgrAgentSettings = new();
public ConfigurationManagerL0()
{
@@ -113,7 +113,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
private TestHostContext CreateTestContext([CallerMemberName] String testName = "")
{
TestHostContext tc = new TestHostContext(this, testName);
TestHostContext tc = new(this, testName);
tc.SetSingleton<ICredentialManager>(_credMgr.Object);
tc.SetSingleton<IPromptManager>(_promptManager.Object);
tc.SetSingleton<IConfigurationStore>(_store.Object);

View File

@@ -12,8 +12,8 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
{
private readonly string _argName = "SomeArgName";
private readonly string _description = "Some description";
private readonly PromptManager _promptManager = new PromptManager();
private readonly Mock<ITerminal> _terminal = new Mock<ITerminal>();
private readonly PromptManager _promptManager = new();
private readonly Mock<ITerminal> _terminal = new();
private readonly string _unattendedExceptionMessage = "Invalid configuration provided for SomeArgName. Terminating unattended configuration.";
[Fact]
@@ -21,7 +21,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "PromptManager")]
public void FallsBackToDefault()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
_terminal
@@ -46,7 +46,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "PromptManager")]
public void FallsBackToDefaultWhenTrimmed()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
_terminal
@@ -71,7 +71,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "PromptManager")]
public void FallsBackToDefaultWhenUnattended()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
_terminal
@@ -98,7 +98,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "PromptManager")]
public void Prompts()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
_terminal
@@ -123,7 +123,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "PromptManager")]
public void PromptsAgainWhenEmpty()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var readLineValues = new Queue<string>(new[] { string.Empty, "Some prompt value" });
@@ -150,7 +150,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "PromptManager")]
public void PromptsAgainWhenFailsValidation()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var readLineValues = new Queue<string>(new[] { "Some invalid prompt value", "Some valid prompt value" });
@@ -177,7 +177,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
[Trait("Category", "PromptManager")]
public void ThrowsWhenUnattended()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
_terminal

View File

@@ -14,7 +14,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
trace.Info("GetVssCredentials()");
var loginCred = new VssOAuthAccessTokenCredential("sometoken");
VssCredentials creds = new VssCredentials(loginCred);
VssCredentials creds = new(loginCred);
trace.Verbose("cred created");
return creds;

View File

@@ -30,7 +30,7 @@ namespace GitHub.Runner.Common.Tests.Listener
private Pipelines.AgentJobRequestMessage CreateJobRequestMessage()
{
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = null;
Guid jobId = Guid.NewGuid();
var result = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "someJob", "someJob", null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -101,10 +101,10 @@ namespace GitHub.Runner.Common.Tests.Listener
int count = 0;
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequest));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
TaskAgentJobRequest request = new TaskAgentJobRequest();
TaskAgentJobRequest request = new();
PropertyInfo lockUntilProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
Assert.NotNull(lockUntilProperty);
lockUntilProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));
@@ -159,10 +159,10 @@ namespace GitHub.Runner.Common.Tests.Listener
int count = 0;
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestStopOnJobNotFoundExceptions));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
TaskAgentJobRequest request = new TaskAgentJobRequest();
TaskAgentJobRequest request = new();
PropertyInfo lockUntilProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
Assert.NotNull(lockUntilProperty);
lockUntilProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));
@@ -218,10 +218,10 @@ namespace GitHub.Runner.Common.Tests.Listener
int count = 0;
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestStopOnJobTokenExpiredExceptions));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
TaskAgentJobRequest request = new TaskAgentJobRequest();
TaskAgentJobRequest request = new();
PropertyInfo lockUntilProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
Assert.NotNull(lockUntilProperty);
lockUntilProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));
@@ -279,8 +279,8 @@ namespace GitHub.Runner.Common.Tests.Listener
var reservedAgent = new TaskAgentReference { Name = newName };
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestStopOnJobTokenExpiredExceptions));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
var request = new Mock<TaskAgentJobRequest>();
request.Object.ReservedAgent = reservedAgent;
@@ -335,8 +335,8 @@ namespace GitHub.Runner.Common.Tests.Listener
var reservedAgent = new TaskAgentReference { Name = newName };
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestStopOnJobTokenExpiredExceptions));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
var request = new Mock<TaskAgentJobRequest>();
request.Object.ReservedAgent = reservedAgent;
@@ -388,8 +388,8 @@ namespace GitHub.Runner.Common.Tests.Listener
var oldSettings = new RunnerSettings { AgentName = oldName };
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestStopOnJobTokenExpiredExceptions));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
var request = new Mock<TaskAgentJobRequest>();
PropertyInfo lockUntilProperty = request.Object.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
@@ -441,10 +441,10 @@ namespace GitHub.Runner.Common.Tests.Listener
int count = 0;
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestRecoverFromExceptions));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
TaskAgentJobRequest request = new TaskAgentJobRequest();
TaskAgentJobRequest request = new();
PropertyInfo lockUntilProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
Assert.NotNull(lockUntilProperty);
lockUntilProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));
@@ -502,10 +502,10 @@ namespace GitHub.Runner.Common.Tests.Listener
int count = 0;
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestFirstRenewRetrySixTimes));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
TaskAgentJobRequest request = new TaskAgentJobRequest();
TaskAgentJobRequest request = new();
PropertyInfo lockUntilProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
Assert.NotNull(lockUntilProperty);
lockUntilProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));
@@ -557,10 +557,10 @@ namespace GitHub.Runner.Common.Tests.Listener
int count = 0;
var trace = hc.GetTrace(nameof(DispatcherRenewJobRequestStopOnExpiredRequest));
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
TaskCompletionSource<int> firstJobRequestRenewed = new();
CancellationTokenSource cancellationTokenSource = new();
TaskAgentJobRequest request = new TaskAgentJobRequest();
TaskAgentJobRequest request = new();
PropertyInfo lockUntilProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
Assert.NotNull(lockUntilProperty);
lockUntilProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));

View File

@@ -36,7 +36,7 @@ namespace GitHub.Runner.Common.Tests.Listener
private TestHostContext CreateTestContext([CallerMemberName] String testName = "")
{
TestHostContext tc = new TestHostContext(this, testName);
TestHostContext tc = new(this, testName);
tc.SetSingleton<IConfigurationManager>(_config.Object);
tc.SetSingleton<IRunnerServer>(_runnerServer.Object);
tc.SetSingleton<ICredentialManager>(_credMgr.Object);
@@ -68,7 +68,7 @@ namespace GitHub.Runner.Common.Tests.Listener
_store.Setup(x => x.GetMigratedCredentials()).Returns(default(CredentialData));
// Act.
MessageListener listener = new MessageListener();
MessageListener listener = new();
listener.Initialize(tc);
bool result = await listener.CreateSessionAsync(tokenSource.Token);
@@ -112,7 +112,7 @@ namespace GitHub.Runner.Common.Tests.Listener
_store.Setup(x => x.GetMigratedCredentials()).Returns(default(CredentialData));
// Act.
MessageListener listener = new MessageListener();
MessageListener listener = new();
listener.Initialize(tc);
bool result = await listener.CreateSessionAsync(tokenSource.Token);
@@ -159,7 +159,7 @@ namespace GitHub.Runner.Common.Tests.Listener
_store.Setup(x => x.GetMigratedCredentials()).Returns(default(CredentialData));
// Act.
MessageListener listener = new MessageListener();
MessageListener listener = new();
listener.Initialize(tc);
bool result = await listener.CreateSessionAsync(tokenSource.Token);
@@ -241,7 +241,7 @@ namespace GitHub.Runner.Common.Tests.Listener
_store.Setup(x => x.GetMigratedCredentials()).Returns(default(CredentialData));
// Act.
MessageListener listener = new MessageListener();
MessageListener listener = new();
listener.Initialize(tc);
bool result = await listener.CreateSessionAsync(tokenSource.Token);
@@ -285,7 +285,7 @@ namespace GitHub.Runner.Common.Tests.Listener
_store.Setup(x => x.GetMigratedCredentials()).Returns(default(CredentialData));
// Act.
MessageListener listener = new MessageListener();
MessageListener listener = new();
listener.Initialize(tc);
bool result = await listener.CreateSessionAsync(tokenSource.Token);

View File

@@ -39,7 +39,7 @@ namespace GitHub.Runner.Common.Tests.Listener
private Pipelines.AgentJobRequestMessage CreateJobRequestMessage(string jobName)
{
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = null;
Guid jobId = Guid.NewGuid();
return new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "test", "test", null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -155,7 +155,7 @@ namespace GitHub.Runner.Common.Tests.Listener
}
}
public static TheoryData<string[], bool, Times> RunAsServiceTestData = new TheoryData<string[], bool, Times>()
public static TheoryData<string[], bool, Times> RunAsServiceTestData = new()
{
// staring with run command, configured as run as service, should start the runner
{ new [] { "run" }, true, Times.Once() },

View File

@@ -22,8 +22,8 @@ namespace GitHub.Runner.Common.Tests.Listener
private Mock<ITerminal> _term;
private Mock<IConfigurationStore> _configStore;
private Mock<IJobDispatcher> _jobDispatcher;
private AgentRefreshMessage _refreshMessage = new AgentRefreshMessage(1, "2.299.0");
private List<TrimmedPackageMetadata> _trimmedPackages = new List<TrimmedPackageMetadata>();
private AgentRefreshMessage _refreshMessage = new(1, "2.299.0");
private List<TrimmedPackageMetadata> _trimmedPackages = new();
#if !OS_WINDOWS
private string _packageUrl = null;
@@ -52,7 +52,7 @@ namespace GitHub.Runner.Common.Tests.Listener
if (response.StatusCode == System.Net.HttpStatusCode.Redirect)
{
var redirectUrl = response.Headers.Location.ToString();
Regex regex = new Regex(@"/runner/releases/tag/v(?<version>\d+\.\d+\.\d+)");
Regex regex = new(@"/runner/releases/tag/v(?<version>\d+\.\d+\.\d+)");
var match = regex.Match(redirectUrl);
if (match.Success)
{

View File

@@ -20,7 +20,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RunnerLayoutParts_NewFilesCrossAll()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
var runnerCoreAssetsFile = Path.Combine(TestUtil.GetSrcPath(), @"Misc/runnercoreassets");
@@ -53,7 +53,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RunnerLayoutParts_OverlapFiles()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
var runnerCoreAssetsFile = Path.Combine(TestUtil.GetSrcPath(), @"Misc/runnercoreassets");
@@ -77,7 +77,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RunnerLayoutParts_NewRunnerCoreAssets()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
var runnerCoreAssetsFile = Path.Combine(TestUtil.GetSrcPath(), @"Misc/runnercoreassets");
@@ -120,7 +120,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RunnerLayoutParts_NewDotnetRuntimeAssets()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
var runnerDotnetRuntimeFile = Path.Combine(TestUtil.GetSrcPath(), @"Misc/runnerdotnetruntimeassets");
@@ -156,7 +156,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RunnerLayoutParts_CheckDotnetRuntimeHash()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
var dotnetRuntimeHashFile = Path.Combine(TestUtil.GetSrcPath(), $"Misc/contentHash/dotnetRuntime/{BuildConstants.RunnerPackage.PackageName}");
@@ -217,7 +217,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RunnerLayoutParts_CheckExternalsHash()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
var externalsHashFile = Path.Combine(TestUtil.GetSrcPath(), $"Misc/contentHash/externals/{BuildConstants.RunnerPackage.PackageName}");

View File

@@ -19,7 +19,7 @@ namespace GitHub.Runner.Common.Tests.Listener
private void CleanLogFolder()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
//clean test data if any old test forgot
string pagesFolder = Path.Combine(hc.GetDirectory(WellKnownDirectory.Diag), PagingLogger.PagingFolder);

View File

@@ -16,7 +16,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task SuccessReadProcessEnv()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();

View File

@@ -63,7 +63,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task SuccessExitsWithCodeZero()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -86,7 +86,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task SetCIEnv()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
var existingCI = Environment.GetEnvironmentVariable("CI");
try
@@ -134,7 +134,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task KeepExistingCIEnv()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
var existingCI = Environment.GetEnvironmentVariable("CI");
try
@@ -185,7 +185,7 @@ namespace GitHub.Runner.Common.Tests
public async Task TestCancel()
{
const int SecondsToRun = 20;
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
using (var tokenSource = new CancellationTokenSource())
{
Tracing trace = hc.GetTrace();
@@ -234,13 +234,13 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RedirectSTDINCloseStream()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
CancellationTokenSource cancellationTokenSource = new();
Int32 exitCode = -1;
Channel<string> redirectSTDIN = Channel.CreateUnbounded<string>(new UnboundedChannelOptions() { SingleReader = true, SingleWriter = true });
List<string> stdout = new List<string>();
List<string> stdout = new();
redirectSTDIN.Writer.TryWrite("Single line of STDIN");
var processInvoker = new ProcessInvokerWrapper();
@@ -284,13 +284,13 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Common")]
public async Task RedirectSTDINKeepStreamOpen()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
CancellationTokenSource cancellationTokenSource = new();
Int32 exitCode = -1;
Channel<string> redirectSTDIN = Channel.CreateUnbounded<string>(new UnboundedChannelOptions() { SingleReader = true, SingleWriter = true });
List<string> stdout = new List<string>();
List<string> stdout = new();
redirectSTDIN.Writer.TryWrite("Single line of STDIN");
var processInvoker = new ProcessInvokerWrapper();
@@ -339,7 +339,7 @@ namespace GitHub.Runner.Common.Tests
string testProcPath = $"/proc/{Process.GetCurrentProcess().Id}/oom_score_adj";
if (File.Exists(testProcPath))
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
using (var tokenSource = new CancellationTokenSource())
{
Tracing trace = hc.GetTrace();
@@ -375,7 +375,7 @@ namespace GitHub.Runner.Common.Tests
string testProcPath = $"/proc/{Process.GetCurrentProcess().Id}/oom_score_adj";
if (File.Exists(testProcPath))
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
using (var tokenSource = new CancellationTokenSource())
{
Tracing trace = hc.GetTrace();
@@ -415,7 +415,7 @@ namespace GitHub.Runner.Common.Tests
{
int testProcOomScoreAdj = 123;
File.WriteAllText(testProcPath, testProcOomScoreAdj.ToString());
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
using (var tokenSource = new CancellationTokenSource())
{
Tracing trace = hc.GetTrace();

View File

@@ -11,9 +11,9 @@ namespace GitHub.Runner.Common.Tests
{
public sealed class RunnerWebProxyL0
{
private static readonly Regex NewHttpClientHandlerRegex = new Regex("New\\s+HttpClientHandler\\s*\\(", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex NewHttpClientRegex = new Regex("New\\s+HttpClient\\s*\\(\\s*\\)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly List<string> SkippedFiles = new List<string>()
private static readonly Regex NewHttpClientHandlerRegex = new("New\\s+HttpClientHandler\\s*\\(", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex NewHttpClientRegex = new("New\\s+HttpClient\\s*\\(\\s*\\)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly List<string> SkippedFiles = new()
{
"Runner.Common\\HostContext.cs",
"Runner.Common/HostContext.cs",
@@ -39,7 +39,7 @@ namespace GitHub.Runner.Common.Tests
"*.cs",
SearchOption.AllDirectories));
List<string> badCode = new List<string>();
List<string> badCode = new();
foreach (string sourceFile in sourceFiles)
{
// Skip skipped files.
@@ -86,7 +86,7 @@ namespace GitHub.Runner.Common.Tests
"*.cs",
SearchOption.AllDirectories));
List<string> badCode = new List<string>();
List<string> badCode = new();
foreach (string sourceFile in sourceFiles)
{
// Skip skipped files.

View File

@@ -11,7 +11,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Service")]
public void CalculateServiceName()
{
RunnerSettings settings = new RunnerSettings();
RunnerSettings settings = new();
settings.AgentName = "thisiskindofalongrunnerabcde";
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
@@ -22,7 +22,7 @@ namespace GitHub.Runner.Common.Tests
using (TestHostContext hc = CreateTestContext())
{
ServiceControlManager scm = new ServiceControlManager();
ServiceControlManager scm = new();
scm.Initialize(hc);
scm.CalculateServiceName(
@@ -50,7 +50,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Service")]
public void CalculateServiceName80Chars()
{
RunnerSettings settings = new RunnerSettings();
RunnerSettings settings = new();
settings.AgentName = "thisiskindofalongrunnernabcde";
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
@@ -61,7 +61,7 @@ namespace GitHub.Runner.Common.Tests
using (TestHostContext hc = CreateTestContext())
{
ServiceControlManager scm = new ServiceControlManager();
ServiceControlManager scm = new();
scm.Initialize(hc);
scm.CalculateServiceName(
@@ -169,7 +169,7 @@ namespace GitHub.Runner.Common.Tests
[Trait("Category", "Service")]
public void CalculateServiceNameLimitsServiceNameTo150Chars()
{
RunnerSettings settings = new RunnerSettings();
RunnerSettings settings = new();
settings.AgentName = "thisisareallyreallylongbutstillvalidagentnameiamusingforthisexampletotestverylongnamelimits";
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
@@ -180,7 +180,7 @@ namespace GitHub.Runner.Common.Tests
using (TestHostContext hc = CreateTestContext())
{
ServiceControlManager scm = new ServiceControlManager();
ServiceControlManager scm = new();
scm.Initialize(hc);
scm.CalculateServiceName(
@@ -206,7 +206,7 @@ namespace GitHub.Runner.Common.Tests
private TestHostContext CreateTestContext([CallerMemberName] string testName = "")
{
TestHostContext hc = new TestHostContext(this, testName);
TestHostContext hc = new(this, testName);
return hc;
}

View File

@@ -17,12 +17,12 @@ namespace GitHub.Runner.Common.Tests
{
public sealed class TestHostContext : IHostContext, IDisposable
{
private readonly ConcurrentDictionary<Type, ConcurrentQueue<object>> _serviceInstances = new ConcurrentDictionary<Type, ConcurrentQueue<object>>();
private readonly ConcurrentDictionary<Type, object> _serviceSingletons = new ConcurrentDictionary<Type, object>();
private readonly ConcurrentDictionary<Type, ConcurrentQueue<object>> _serviceInstances = new();
private readonly ConcurrentDictionary<Type, object> _serviceSingletons = new();
private readonly ITraceManager _traceManager;
private readonly Terminal _term;
private readonly SecretMasker _secretMasker;
private CancellationTokenSource _runnerShutdownTokenSource = new CancellationTokenSource();
private CancellationTokenSource _runnerShutdownTokenSource = new();
private string _suiteName;
private string _testName;
private Tracing _trace;
@@ -86,9 +86,9 @@ namespace GitHub.Runner.Common.Tests
}
}
public List<ProductInfoHeaderValue> UserAgents => new List<ProductInfoHeaderValue>() { new ProductInfoHeaderValue("L0Test", "0.0") };
public List<ProductInfoHeaderValue> UserAgents => new() { new ProductInfoHeaderValue("L0Test", "0.0") };
public RunnerWebProxy WebProxy => new RunnerWebProxy();
public RunnerWebProxy WebProxy => new();
public async Task Delay(TimeSpan delay, CancellationToken token)
{

View File

@@ -11,7 +11,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Equal_MatchesObjectEquality()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -29,12 +29,12 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Equal_MatchesReferenceEquality()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
// Arrange.
object expected = new object();
object expected = new();
object actual = expected;
// Act/Assert.
@@ -47,7 +47,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Equal_MatchesStructEquality()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -65,12 +65,12 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Equal_ThrowsWhenActualObjectIsNull()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
// Arrange.
object expected = new object();
object expected = new();
object actual = null;
// Act/Assert.
@@ -86,13 +86,13 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Equal_ThrowsWhenExpectedObjectIsNull()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
// Arrange.
object expected = null;
object actual = new object();
object actual = new();
// Act/Assert.
Assert.Throws<ArgumentOutOfRangeException>(() =>
@@ -107,13 +107,13 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Equal_ThrowsWhenObjectsAreNotEqual()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
// Arrange.
object expected = new object();
object actual = new object();
object expected = new();
object actual = new();
// Act/Assert.
Assert.Throws<ArgumentOutOfRangeException>(() =>
@@ -128,7 +128,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Equal_ThrowsWhenStructsAreNotEqual()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();

View File

@@ -15,7 +15,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Delete_DeletesDirectory()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -49,7 +49,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void Delete_DeletesFile()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -83,7 +83,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteDirectory_DeletesDirectoriesRecursively()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -115,7 +115,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public async Task DeleteDirectory_DeletesDirectoryReparsePointChain()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -179,7 +179,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public async Task DeleteDirectory_DeletesDirectoryReparsePointsBeforeDirectories()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -230,7 +230,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteDirectory_DeletesFilesRecursively()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -264,7 +264,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteDirectory_DeletesReadOnlyDirectories()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -305,7 +305,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteDirectory_DeletesReadOnlyRootDirectory()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -341,7 +341,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteDirectory_DeletesReadOnlyFiles()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -381,7 +381,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public async Task DeleteDirectory_DoesNotFollowDirectoryReparsePoint()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -428,7 +428,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public async Task DeleteDirectory_DoesNotFollowNestLevel1DirectoryReparsePoint()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -477,7 +477,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public async Task DeleteDirectory_DoesNotFollowNestLevel2DirectoryReparsePoint()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -528,7 +528,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteDirectory_IgnoresFile()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -563,7 +563,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteFile_DeletesFile()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -597,7 +597,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteFile_DeletesReadOnlyFile()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -637,7 +637,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void DeleteFile_IgnoresDirectory()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -670,7 +670,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void GetRelativePath()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -768,7 +768,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void ResolvePath()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -867,7 +867,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void ValidateExecutePermission_DoesNotExceedFailsafe()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -896,7 +896,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void ValidateExecutePermission_ExceedsFailsafe()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();

View File

@@ -12,7 +12,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void FormatAlwaysCallsFormat()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -48,7 +48,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void FormatHandlesFormatException()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();
@@ -79,7 +79,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void FormatUsesInvariantCulture()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
CultureInfo originalCulture = CultureInfo.CurrentCulture;
@@ -105,7 +105,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void ConvertNullOrEmptryStringToBool()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
string nullString = null;
@@ -126,7 +126,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void ConvertNullOrEmptryStringToDefaultBool()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
string nullString = null;
@@ -147,7 +147,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void ConvertStringToBool()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
string trueString1 = "1";

View File

@@ -12,7 +12,7 @@ namespace GitHub.Runner.Common.Tests.Util
public void TaskResultReturnCodeTranslate()
{
// Arrange.
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Act.
TaskResult abandon = TaskResultUtil.TranslateFromReturnCode(TaskResultUtil.TranslateToReturnCode(TaskResult.Abandoned));
@@ -57,7 +57,7 @@ namespace GitHub.Runner.Common.Tests.Util
public void TaskResultsMerge()
{
// Arrange.
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
TaskResult merged;

View File

@@ -12,7 +12,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void VerifyOverwriteVssConnectionSetting()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
Tracing trace = hc.GetTrace();

View File

@@ -13,7 +13,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void UseWhichFindGit()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
//Arrange
Tracing trace = hc.GetTrace();
@@ -33,7 +33,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void WhichReturnsNullWhenNotFound()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
//Arrange
Tracing trace = hc.GetTrace();
@@ -53,7 +53,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void WhichThrowsWhenRequireAndNotFound()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
//Arrange
Tracing trace = hc.GetTrace();
@@ -76,7 +76,7 @@ namespace GitHub.Runner.Common.Tests.Util
[Trait("Category", "Common")]
public void WhichHandleFullyQualifiedPath()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
//Arrange
Tracing trace = hc.GetTrace();

View File

@@ -18,7 +18,7 @@ namespace GitHub.Runner.Common.Tests.Worker
string message;
ActionCommand test;
ActionCommand verify;
HashSet<string> commands = new HashSet<string>() { "do-something" };
HashSet<string> commands = new() { "do-something" };
//##[do-something k1=v1;]msg
message = "##[do-something k1=v1;]msg";
test = new ActionCommand("do-something")
@@ -99,7 +99,7 @@ namespace GitHub.Runner.Common.Tests.Worker
string message;
ActionCommand test;
ActionCommand verify;
HashSet<string> commands = new HashSet<string>() { "do-something" };
HashSet<string> commands = new() { "do-something" };
//::do-something k1=v1;]msg
message = "::do-something k1=v1,::msg";
test = new ActionCommand("do-something")

View File

@@ -228,8 +228,8 @@ namespace GitHub.Runner.Common.Tests.Worker
{
// Set up a few things
// 1. Job request message (with ACTIONS_STEP_DEBUG = true)
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);

View File

@@ -1028,7 +1028,7 @@ namespace GitHub.Runner.Common.Tests.Worker
//Arrange
Setup();
Pipelines.ActionStep instance = new Pipelines.ActionStep()
Pipelines.ActionStep instance = new()
{
Id = Guid.NewGuid(),
Reference = new Pipelines.ContainerRegistryReference()
@@ -1065,7 +1065,7 @@ namespace GitHub.Runner.Common.Tests.Worker
//Arrange
Setup();
Pipelines.ActionStep instance = new Pipelines.ActionStep()
Pipelines.ActionStep instance = new()
{
Id = Guid.NewGuid(),
Reference = new Pipelines.ScriptReference()
@@ -1137,7 +1137,7 @@ runs:
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1236,7 +1236,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1328,7 +1328,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1397,7 +1397,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1479,7 +1479,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1555,7 +1555,7 @@ runs:
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1653,7 +1653,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1745,7 +1745,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1814,7 +1814,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1893,7 +1893,7 @@ runs:
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;
@@ -1983,7 +1983,7 @@ runs:
Assert.Equal(directory, definition.Directory);
Assert.NotNull(definition.Data);
Assert.NotNull(definition.Data.Inputs); // inputs
Dictionary<string, string> inputDefaults = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> inputDefaults = new(StringComparer.OrdinalIgnoreCase);
foreach (var input in definition.Data.Inputs)
{
var name = input.Key.AssertString("key").Value;

View File

@@ -34,7 +34,7 @@ namespace GitHub.Runner.Common.Tests.Worker
private IActionManifestManager _actionManifestManager;
private Mock<IFileCommandManager> _fileCommandManager;
private DictionaryContextData _context = new DictionaryContextData();
private DictionaryContextData _context = new();
[Fact]
[Trait("Level", "L0")]
@@ -60,7 +60,7 @@ namespace GitHub.Runner.Common.Tests.Worker
_actionRunner.Action = action;
Dictionary<string, string> finialInputs = new Dictionary<string, string>();
Dictionary<string, string> finialInputs = new();
_handlerFactory.Setup(x => x.Create(It.IsAny<IExecutionContext>(), It.IsAny<ActionStepDefinitionReference>(), It.IsAny<IStepHost>(), It.IsAny<ActionExecutionData>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Variables>(), It.IsAny<string>(), It.IsAny<List<JobExtensionRunner>>()))
.Callback((IExecutionContext executionContext, Pipelines.ActionStepDefinitionReference actionReference, IStepHost stepHost, ActionExecutionData data, Dictionary<string, string> inputs, Dictionary<string, string> environment, Variables runtimeVariables, string taskDirectory, List<JobExtensionRunner> localActionContainerSetupSteps) =>
{
@@ -106,7 +106,7 @@ namespace GitHub.Runner.Common.Tests.Worker
_actionRunner.Action = action;
Dictionary<string, string> finialInputs = new Dictionary<string, string>();
Dictionary<string, string> finialInputs = new();
_handlerFactory.Setup(x => x.Create(It.IsAny<IExecutionContext>(), It.IsAny<ActionStepDefinitionReference>(), It.IsAny<IStepHost>(), It.IsAny<ActionExecutionData>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Variables>(), It.IsAny<string>(), It.IsAny<List<JobExtensionRunner>>()))
.Callback((IExecutionContext executionContext, Pipelines.ActionStepDefinitionReference actionReference, IStepHost stepHost, ActionExecutionData data, Dictionary<string, string> inputs, Dictionary<string, string> environment, Variables runtimeVariables, string taskDirectory, List<JobExtensionRunner> localActionContainerSetupSteps) =>
{
@@ -307,7 +307,7 @@ namespace GitHub.Runner.Common.Tests.Worker
_actionRunner.Action = action;
Dictionary<string, string> finialInputs = new Dictionary<string, string>();
Dictionary<string, string> finialInputs = new();
_handlerFactory.Setup(x => x.Create(It.IsAny<IExecutionContext>(), It.IsAny<ActionStepDefinitionReference>(), It.IsAny<IStepHost>(), It.IsAny<ActionExecutionData>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Variables>(), It.IsAny<string>(), It.IsAny<List<JobExtensionRunner>>()))
.Callback((IExecutionContext executionContext, Pipelines.ActionStepDefinitionReference actionReference, IStepHost stepHost, ActionExecutionData data, Dictionary<string, string> inputs, Dictionary<string, string> environment, Variables runtimeVariables, string taskDirectory, List<JobExtensionRunner> localActionContainerSetupSteps) =>
{
@@ -358,7 +358,7 @@ namespace GitHub.Runner.Common.Tests.Worker
_actionRunner.Action = action;
Dictionary<string, string> finialInputs = new Dictionary<string, string>();
Dictionary<string, string> finialInputs = new();
_handlerFactory.Setup(x => x.Create(It.IsAny<IExecutionContext>(), It.IsAny<ActionStepDefinitionReference>(), It.IsAny<IStepHost>(), It.IsAny<ActionExecutionData>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Variables>(), It.IsAny<string>(), It.IsAny<List<JobExtensionRunner>>()))
.Callback((IExecutionContext executionContext, Pipelines.ActionStepDefinitionReference actionReference, IStepHost stepHost, ActionExecutionData data, Dictionary<string, string> inputs, Dictionary<string, string> environment, Variables runtimeVariables, string taskDirectory, List<JobExtensionRunner> localActionContainerSetupSteps) =>
{

View File

@@ -22,12 +22,12 @@ namespace GitHub.Runner.Common.Tests.Worker
private ContainerOperationProvider containerOperationProvider;
private Mock<IJobServerQueue> serverQueue;
private Mock<IPagingLogger> pagingLogger;
private List<string> healthyDockerStatus = new List<string> { "healthy" };
private List<string> emptyDockerStatus = new List<string> { string.Empty };
private List<string> unhealthyDockerStatus = new List<string> { "unhealthy" };
private List<string> dockerLogs = new List<string> { "log1", "log2", "log3" };
private List<string> healthyDockerStatus = new() { "healthy" };
private List<string> emptyDockerStatus = new() { string.Empty };
private List<string> unhealthyDockerStatus = new() { "unhealthy" };
private List<string> dockerLogs = new() { "log1", "log2", "log3" };
List<ContainerInfo> containers = new List<ContainerInfo>();
List<ContainerInfo> containers = new();
[Fact]
[Trait("Level", "L0")]

View File

@@ -189,8 +189,8 @@ namespace GitHub.Runner.Common.Tests.Worker
_issues = new List<Tuple<DTWebApi.Issue, string>>();
// Setup a job request
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "Summary Job";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);

View File

@@ -25,8 +25,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -101,8 +101,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -157,8 +157,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -211,8 +211,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -260,8 +260,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -311,8 +311,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -409,8 +409,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -493,8 +493,8 @@ namespace GitHub.Runner.Common.Tests.Worker
{
using (TestHostContext hc = CreateTestContext())
{
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -548,8 +548,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -591,8 +591,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -655,8 +655,8 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = CreateTestContext())
{
// Arrange: Create a job request message.
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);
@@ -851,8 +851,8 @@ namespace GitHub.Runner.Common.Tests.Worker
{
using (TestHostContext hc = CreateTestContext())
{
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TimelineReference timeline = new TimelineReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new();
Guid jobId = Guid.NewGuid();
string jobName = "some job name";
var jobRequest = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, jobName, jobName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);

View File

@@ -56,7 +56,7 @@ namespace GitHub.Runner.Common.Tests.Worker
{
variables["DistributedTask.ForceGithubJavascriptActionsToNode16"] = serverFeatureFlag;
}
Variables serverVariables = new Variables(hc, variables);
Variables serverVariables = new(hc, variables);
// Workflow opt-out
var workflowVariables = new Dictionary<string, string>();

View File

@@ -67,10 +67,10 @@ namespace GitHub.Runner.Common.Tests.Worker
}
_tokenSource = new CancellationTokenSource();
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new Timeline(Guid.NewGuid());
List<Pipelines.ActionStep> steps = new List<Pipelines.ActionStep>()
List<Pipelines.ActionStep> steps = new()
{
new Pipelines.ActionStep()
{
@@ -101,7 +101,7 @@ namespace GitHub.Runner.Common.Tests.Worker
Guid jobId = Guid.NewGuid();
_message = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, "test", "test", null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), steps, null, null, null, null);
GitHubContext github = new GitHubContext();
GitHubContext github = new();
github["repository"] = new Pipelines.ContextData.StringContextData("actions/runner");
github["secret_source"] = new Pipelines.ContextData.StringContextData("Actions");
_message.ContextData.Add("github", github);

View File

@@ -15,7 +15,7 @@ namespace GitHub.Runner.Common.Tests.Worker
{
private IExecutionContext _jobEc;
private JobRunner _jobRunner;
private List<IStep> _initResult = new List<IStep>();
private List<IStep> _initResult = new();
private Pipelines.AgentJobRequestMessage _message;
private CancellationTokenSource _tokenSource;
private Mock<IJobServer> _jobServer;
@@ -55,7 +55,7 @@ namespace GitHub.Runner.Common.Tests.Worker
_jobRunner = new JobRunner();
_jobRunner.Initialize(hc);
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
TaskOrchestrationPlanReference plan = new();
TimelineReference timeline = new Timeline(Guid.NewGuid());
Guid jobId = Guid.NewGuid();
_message = new Pipelines.AgentJobRequestMessage(plan, timeline, jobId, testName, testName, null, null, null, new Dictionary<string, VariableValue>(), new List<MaskHint>(), new Pipelines.JobResources(), new Pipelines.ContextData.DictionaryContextData(), new Pipelines.WorkspaceOptions(), new List<Pipelines.ActionStep>(), null, null, null, null);

View File

@@ -199,13 +199,13 @@ namespace GitHub.Runner.Common.Tests.Worker
[CallerMemberName] string name = "")
{
// Setup the host context.
TestHostContext hc = new TestHostContext(this, name);
TestHostContext hc = new(this, name);
// Setup the execution context.
_ec = new Mock<IExecutionContext>();
_ec.Setup(x => x.Global).Returns(new GlobalContext());
GitHubContext githubContext = new GitHubContext();
GitHubContext githubContext = new();
_ec.Setup(x => x.GetGitHubContext("repository")).Returns("actions/runner");
// Store the expected tracking file path.

View File

@@ -27,7 +27,7 @@ namespace GitHub.Runner.Common.Tests.Worker
private TestHostContext CreateTestContext([CallerMemberName] String testName = "")
{
var hc = new TestHostContext(this, testName);
Dictionary<string, VariableValue> variablesToCopy = new Dictionary<string, VariableValue>();
Dictionary<string, VariableValue> variablesToCopy = new();
_variables = new Variables(
hostContext: hc,
copy: variablesToCopy);

View File

@@ -16,14 +16,14 @@ namespace GitHub.Runner.Common.Tests.Worker
public TestHostContext Setup([CallerMemberName] string name = "")
{
// Setup the host context.
TestHostContext hc = new TestHostContext(this, name);
TestHostContext hc = new(this, name);
// Create a random work path.
_workFolder = hc.GetDirectory(WellKnownDirectory.Work);
// Setup the execution context.
_ec = new Mock<IExecutionContext>();
GitHubContext githubContext = new GitHubContext();
GitHubContext githubContext = new();
_ec.Setup(x => x.GetGitHubContext("repository")).Returns("actions/runner");
// Setup the tracking manager.
@@ -113,7 +113,7 @@ namespace GitHub.Runner.Common.Tests.Worker
using (TestHostContext hc = Setup())
{
// Arrange.
TrackingConfig config = new TrackingConfig() { RepositoryName = "actions/runner" };
TrackingConfig config = new() { RepositoryName = "actions/runner" };
string trackingFile = Path.Combine(_workFolder, "trackingconfig.json");
// Act.

View File

@@ -14,7 +14,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void Constructor_AppliesMaskHints()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var copy = new Dictionary<string, VariableValue>
@@ -36,7 +36,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void Constructor_HandlesNullValue()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var copy = new Dictionary<string, VariableValue>
@@ -59,7 +59,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void Constructor_SetsNullAsEmpty()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var copy = new Dictionary<string, VariableValue>
@@ -80,7 +80,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void Constructor_SetsOrdinalIgnoreCaseComparer()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
CultureInfo currentCulture = CultureInfo.CurrentCulture;
@@ -115,7 +115,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void Constructor_SkipVariableWithEmptyName()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var copy = new Dictionary<string, VariableValue>
@@ -139,7 +139,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void Get_ReturnsNullIfNotFound()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var variables = new Variables(hc, new Dictionary<string, VariableValue>());
@@ -157,7 +157,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void GetBoolean_DoesNotThrowWhenNull()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var variables = new Variables(hc, new Dictionary<string, VariableValue>());
@@ -175,7 +175,7 @@ namespace GitHub.Runner.Common.Tests.Worker
[Trait("Category", "Worker")]
public void GetEnum_DoesNotThrowWhenNull()
{
using (TestHostContext hc = new TestHostContext(this))
using (TestHostContext hc = new(this))
{
// Arrange.
var variables = new Variables(hc, new Dictionary<string, VariableValue>());

View File

@@ -25,17 +25,17 @@ namespace GitHub.Runner.Common.Tests.Worker
private Pipelines.AgentJobRequestMessage CreateJobRequestMessage(string jobName)
{
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference() { PlanId = Guid.NewGuid() };
TaskOrchestrationPlanReference plan = new() { PlanId = Guid.NewGuid() };
TimelineReference timeline = null;
Dictionary<string, VariableValue> variables = new Dictionary<string, VariableValue>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, VariableValue> variables = new(StringComparer.OrdinalIgnoreCase);
variables[Constants.Variables.System.Culture] = "en-US";
Pipelines.JobResources resources = new Pipelines.JobResources();
Pipelines.JobResources resources = new();
var serviceEndpoint = new ServiceEndpoint();
serviceEndpoint.Authorization = new EndpointAuthorization();
serviceEndpoint.Authorization.Parameters.Add("nullValue", null);
resources.Endpoints.Add(serviceEndpoint);
List<Pipelines.ActionStep> actions = new List<Pipelines.ActionStep>();
List<Pipelines.ActionStep> actions = new();
actions.Add(new Pipelines.ActionStep()
{
Id = Guid.NewGuid(),