Skip to content

Commit 311f97d

Browse files
EvangelinkCopilot
andauthored
[code-simplifier] refactor: simplify nested ternary and duplicate assignments in recent changes (#9477)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5731c45 commit 311f97d

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/Adapter/MSTestAdapter.PlatformServices/MSTestSettings.Configuration.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,12 @@ internal static void SetSettingsFromConfig(IConfiguration configuration, IMessag
212212

213213
if (configuration["mstest:parallelism:workers"] is string workers)
214214
{
215-
settings.ParallelizationWorkers = int.TryParse(workers, out int parallelWorkers)
216-
? parallelWorkers == 0
217-
? Environment.ProcessorCount
218-
: parallelWorkers > 0
219-
? parallelWorkers
220-
: throw new AdapterSettingsException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidParallelWorkersValue, workers))
221-
: throw new AdapterSettingsException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidParallelWorkersValue, workers));
215+
if (!int.TryParse(workers, out int parallelWorkers) || parallelWorkers < 0)
216+
{
217+
throw new AdapterSettingsException(string.Format(CultureInfo.CurrentCulture, Resource.InvalidParallelWorkersValue, workers));
218+
}
219+
220+
settings.ParallelizationWorkers = parallelWorkers == 0 ? Environment.ProcessorCount : parallelWorkers;
222221
}
223222

224223
if (configuration["mstest:parallelism:scope"] is string value)

src/Platform/Microsoft.Testing.Extensions.VideoRecorder/VideoRecorderSessionHandler.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,19 @@ public VideoRecorderSessionHandler(
7676
_options = options;
7777

7878
_enabled = commandLineOptions.IsOptionSet(VideoRecorderCommandLineProvider.EnableOptionName);
79-
if (!_enabled)
79+
if (_enabled)
8080
{
81-
_persistMode = options.PersistMode;
82-
_granularity = options.Granularity;
83-
return;
81+
ApplyCommandLineOverrides(options, commandLineOptions);
8482
}
8583

86-
ApplyCommandLineOverrides(options, commandLineOptions);
8784
_persistMode = options.PersistMode;
8885
_granularity = options.Granularity;
8986

87+
if (!_enabled)
88+
{
89+
return;
90+
}
91+
9092
string outputDirectory = options.OutputDirectory
9193
?? Path.Combine(configuration.GetTestResultDirectory(), "VideoRecordings");
9294

0 commit comments

Comments
 (0)