diff --git a/DotnetAdapters.sln.DotSettings b/DotnetAdapters.sln.DotSettings
new file mode 100644
index 0000000..8a4b9fa
--- /dev/null
+++ b/DotnetAdapters.sln.DotSettings
@@ -0,0 +1,4 @@
+
+ True
+ True
+ True
\ No newline at end of file
diff --git a/Tms.Adapter.Core/Tms.Adapter.Core.csproj b/Tms.Adapter.Core/Tms.Adapter.Core.csproj
index 7d036c8..7048b82 100644
--- a/Tms.Adapter.Core/Tms.Adapter.Core.csproj
+++ b/Tms.Adapter.Core/Tms.Adapter.Core.csproj
@@ -1,7 +1,7 @@
- 1.4.1
+ 1.4.2
netstandard2.1
enable
true
diff --git a/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj b/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj
index 6291f45..79363ab 100644
--- a/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj
+++ b/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj
@@ -1,7 +1,7 @@
- 1.4.1
+ 1.4.2
netstandard2.1
enable
true
diff --git a/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj b/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj
index 4349989..2cfebab 100644
--- a/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj
+++ b/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj
@@ -1,7 +1,7 @@
- 1.4.1
+ 1.4.2
netstandard2.1
enable
true
diff --git a/Tms.Adapter/Tms.Adapter.csproj b/Tms.Adapter/Tms.Adapter.csproj
index 532b3d3..3963956 100644
--- a/Tms.Adapter/Tms.Adapter.csproj
+++ b/Tms.Adapter/Tms.Adapter.csproj
@@ -1,7 +1,7 @@
- 1.4.1
+ 1.4.2
netstandard2.1
enable
true
diff --git a/TmsRunner/Handlers/DiscoveryEventHandler.cs b/TmsRunner/Handlers/DiscoveryEventHandler.cs
index 55719e8..e21e074 100644
--- a/TmsRunner/Handlers/DiscoveryEventHandler.cs
+++ b/TmsRunner/Handlers/DiscoveryEventHandler.cs
@@ -6,7 +6,7 @@
namespace TmsRunner.Handlers;
public sealed class DiscoveryEventHandler(ILogger logger,
- AutoResetEvent waitHandle) : ITestDiscoveryEventsHandler, IDisposable
+ EventWaitHandle waitHandle) : ITestDiscoveryEventsHandler, IDisposable
{
private readonly List _discoveredTestCases = [];
@@ -19,9 +19,10 @@ public void HandleDiscoveredTests(IEnumerable? discoveredTestCases)
return;
}
- _discoveredTestCases.AddRange(discoveredTestCases);
+ var testCases = discoveredTestCases.ToArray();
+ _discoveredTestCases.AddRange(testCases);
- logger.LogDebug("Added test cases: {@TestCases}", discoveredTestCases.Select(t => t.FullyQualifiedName));
+ logger.LogDebug("Added test cases: {@TestCases}", testCases.Select(t => t.FullyQualifiedName));
}
public void HandleDiscoveryComplete(long totalTests, IEnumerable? lastChunk, bool isAborted)
@@ -58,7 +59,7 @@ public List GetTestCases()
public void Dispose()
{
- _discoveredTestCases?.Clear();
- waitHandle?.Dispose();
+ _discoveredTestCases.Clear();
+ waitHandle.Dispose();
}
}
\ No newline at end of file
diff --git a/TmsRunner/Handlers/RunEventHandler.cs b/TmsRunner/Handlers/RunEventHandler.cs
index 9d0e10a..d119199 100644
--- a/TmsRunner/Handlers/RunEventHandler.cs
+++ b/TmsRunner/Handlers/RunEventHandler.cs
@@ -6,7 +6,7 @@
namespace TmsRunner.Handlers;
-public sealed class RunEventHandler(ILogger logger, AutoResetEvent waitHandle,
+public sealed class RunEventHandler(ILogger logger, EventWaitHandle waitHandle,
ProcessorService processorService) : ITestRunEventsHandler, IDisposable
{
private readonly List _processTestResultsTasks = [];
@@ -21,7 +21,7 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs,
ICollection? runContextAttachments,
ICollection? executorUris)
{
- if (lastChunkArgs != null && lastChunkArgs.NewTestResults != null)
+ if (lastChunkArgs is { NewTestResults: not null })
{
_processTestResultsTasks.Add(ProcessTestResultsAsync(lastChunkArgs.NewTestResults));
}
@@ -32,7 +32,7 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs testRunCompleteArgs,
public void HandleTestRunStatsChange(TestRunChangedEventArgs? testRunChangedArgs)
{
- if (testRunChangedArgs != null && testRunChangedArgs.NewTestResults != null)
+ if (testRunChangedArgs is { NewTestResults: not null })
{
_processTestResultsTasks.Add(ProcessTestResultsAsync(testRunChangedArgs.NewTestResults));
}
@@ -67,7 +67,7 @@ public List GetProcessTestResultsTasks()
private async Task ProcessTestResultsAsync(IEnumerable? testResults)
{
- if (testResults == null || !testResults.Any())
+ if (testResults == null)
{
return;
}
@@ -96,7 +96,7 @@ private async Task ProcessTestResultsAsync(IEnumerable? testResults
public void Dispose()
{
- _processTestResultsTasks?.Clear();
- waitHandle?.Dispose();
+ _processTestResultsTasks.Clear();
+ waitHandle.Dispose();
}
}
\ No newline at end of file
diff --git a/TmsRunner/Models/AutoTest/AutoTest.cs b/TmsRunner/Models/AutoTest/AutoTest.cs
index 9ff2df6..c7b821e 100644
--- a/TmsRunner/Models/AutoTest/AutoTest.cs
+++ b/TmsRunner/Models/AutoTest/AutoTest.cs
@@ -4,19 +4,19 @@ namespace TmsRunner.Models.AutoTest;
public sealed record AutoTest
{
- public string? Namespace { get; set; }
- public string? Classname { get; set; }
- public List Steps { get; set; } = [];
- public List? Setup { get; set; }
- public List? Teardown { get; set; }
- public string? ExternalId { get; set; }
- public string? Name { get; set; }
- public string? Title { get; set; }
- public string? Description { get; set; }
- public List WorkItemIds { get; set; } = [];
- public List? Links { get; set; } = [];
- public List? Labels { get; set; }
- public string? MethodName { get; set; }
- public string? Message { get; set; }
- public bool? IsFlaky { get; set; }
+ public string? Namespace;
+ public string? Classname;
+ public List Steps = [];
+ public List? Setup;
+ public List? Teardown;
+ public string? ExternalId;
+ public string? Name;
+ public string? Title;
+ public string? Description;
+ public List WorkItemIds = [];
+ public List? Links = [];
+ public List? Labels;
+ public string? MethodName;
+ public string? Message;
+ public bool? IsFlaky;
}
\ No newline at end of file
diff --git a/TmsRunner/Models/AutoTest/AutoTestResult.cs b/TmsRunner/Models/AutoTest/AutoTestResult.cs
index 548e132..b109694 100644
--- a/TmsRunner/Models/AutoTest/AutoTestResult.cs
+++ b/TmsRunner/Models/AutoTest/AutoTestResult.cs
@@ -5,17 +5,17 @@ namespace TmsRunner.Models.AutoTest;
public sealed record AutoTestResult
{
- public List? Links { get; set; }
- public string? Message { get; set; }
- public string? ExternalId { get; set; }
- public TestOutcome? Outcome { get; set; }
- public string? Traces { get; set; }
- public DateTime? StartedOn { get; set; }
- public DateTime? CompletedOn { get; set; }
- public long? Duration { get; set; }
- public List? Attachments { get; set; }
- public Dictionary? Parameters { get; set; }
- public List? StepResults { get; set; }
- public List? SetupResults { get; set; }
- public List? TeardownResults { get; set; }
+ public List? Links;
+ public string? Message;
+ public string? ExternalId;
+ public TestOutcome? Outcome;
+ public string? Traces;
+ public DateTime? StartedOn;
+ public DateTime? CompletedOn;
+ public long? Duration;
+ public List? Attachments;
+ public Dictionary? Parameters;
+ public List? StepResults;
+ public List? SetupResults;
+ public List? TeardownResults;
}
\ No newline at end of file
diff --git a/TmsRunner/Models/AutoTest/AutoTestStep.cs b/TmsRunner/Models/AutoTest/AutoTestStep.cs
index 6cffe12..54b9e58 100644
--- a/TmsRunner/Models/AutoTest/AutoTestStep.cs
+++ b/TmsRunner/Models/AutoTest/AutoTestStep.cs
@@ -2,9 +2,9 @@ namespace TmsRunner.Models.AutoTest;
public sealed record AutoTestStep
{
- public string? Title { get; set; }
- public string? Description { get; set; }
- public List? Steps { get; set; }
+ public string? Title;
+ public string? Description;
+ public List? Steps;
public static AutoTestStep ConvertFromStep(Step step)
{
diff --git a/TmsRunner/Models/AutoTest/AutoTestStepResult.cs b/TmsRunner/Models/AutoTest/AutoTestStepResult.cs
index acab42d..689fabf 100644
--- a/TmsRunner/Models/AutoTest/AutoTestStepResult.cs
+++ b/TmsRunner/Models/AutoTest/AutoTestStepResult.cs
@@ -2,15 +2,15 @@ namespace TmsRunner.Models.AutoTest;
public sealed record AutoTestStepResult
{
- public string? Title { get; set; }
- public string? Description { get; set; }
- public DateTime? StartedOn { get; set; }
- public DateTime? CompletedOn { get; set; }
- public long? Duration { get; set; }
- public List? Attachments { get; set; }
- public Dictionary? Parameters { get; set; }
- public List? Steps { get; set; }
- public string? Outcome { get; set; }
+ public string? Title;
+ public string? Description;
+ public DateTime? StartedOn;
+ public DateTime? CompletedOn;
+ public long? Duration;
+ public List? Attachments;
+ public Dictionary? Parameters;
+ public List? Steps;
+ public string? Outcome;
public static AutoTestStepResult ConvertFromStep(Step step)
{
diff --git a/TmsRunner/Models/Configuration/AdapterConfig.cs b/TmsRunner/Models/Configuration/AdapterConfig.cs
index 8436454..e719749 100644
--- a/TmsRunner/Models/Configuration/AdapterConfig.cs
+++ b/TmsRunner/Models/Configuration/AdapterConfig.cs
@@ -4,28 +4,22 @@ namespace TmsRunner.Models.Configuration;
public sealed class AdapterConfig
{
- [Option('r', "runner", Required = true,
- HelpText =
- "Set path to test runner. Example: --runner '/opt/homebrew/Cellar/dotnet/6.0.110/libexec/sdk/6.0.110/vstest.console.dll'")]
+ [Option('r', "runner", Required = true, HelpText = "Set path to test runner. Example: --runner '/opt/homebrew/Cellar/dotnet/6.0.110/libexec/sdk/6.0.110/vstest.console.dll'")]
public string? RunnerPath { get; set; }
- [Option('t', "testassembly", Required = true,
- HelpText = "Set path to test assembly. Example: --testassembly '/Tests/tests.dll'")]
+ [Option('t', "testassembly", Required = true, HelpText = "Set path to test assembly. Example: --testassembly '/Tests/tests.dll'")]
public string? TestAssemblyPath { get; set; }
- [Option('a', "testadapter", Required = false,
- HelpText = "Set path to test adapter. Example: --testadapter '/Tests/testsAdapter.dll'")]
+ [Option('a', "testadapter", Required = false, HelpText = "Set path to test adapter. Example: --testadapter '/Tests/testsAdapter.dll'")]
public string? TestAdapterPath { get; set; }
- [Option('l', "logger", Required = false,
- HelpText = "Set path to logger. Example: --logger '/Tests/logger.dll'")]
+ [Option('l', "logger", Required = false, HelpText = "Set path to logger. Example: --logger '/Tests/logger.dll'")]
public string? LoggerPath { get; set; }
[Option("tmsLabelsOfTestsToRun", Required = false, HelpText = "Set labels of autotests to run. Example: --tmsLabelsOfTestsToRun smoke OR --tmsLabelsOfTestsToRun smoke,prod,cloud")]
public string? TmsLabelsOfTestsToRun { get; set; }
- [Option('d', "debug", Required = false,
- HelpText = "Set debug level for logging. Example: --debug")]
+ [Option('d', "debug", Required = false, HelpText = "Set debug level for logging. Example: --debug")]
public bool IsDebug { get; set; }
[Option("tmsUrl", Required = false, HelpText = "Set TMS host address.")]
diff --git a/TmsRunner/Models/Configuration/Config.cs b/TmsRunner/Models/Configuration/Config.cs
index 9dfcb8b..a1d422c 100644
--- a/TmsRunner/Models/Configuration/Config.cs
+++ b/TmsRunner/Models/Configuration/Config.cs
@@ -2,27 +2,16 @@ namespace TmsRunner.Models.Configuration;
public sealed record Config
{
- public string? TmsUrl { get; set; }
-
- public string? TmsPrivateToken { get; set; }
-
- public string? TmsProjectId { get; set; }
-
- public string? TmsConfigurationId { get; set; }
-
- public string? TmsTestRunId { get; set; }
-
- public string? TmsTestRunName { get; set; }
-
- public string? TmsAdapterMode { get; set; }
-
- public string? TmsConfigFile { get; set; }
-
- public string? TmsRunSettings { get; set; }
-
- public string? TmsAutomaticCreationTestCases { get; set; }
-
- public string? TmsCertValidation { get; set; }
-
- public string? TmsLabelsOfTestsToRun { get; set; }
+ public string? TmsUrl;
+ public string? TmsPrivateToken;
+ public string? TmsProjectId;
+ public string? TmsConfigurationId;
+ public string? TmsTestRunId;
+ public string? TmsTestRunName;
+ public string? TmsAdapterMode;
+ public string? TmsConfigFile;
+ public string? TmsRunSettings;
+ public string? TmsAutomaticCreationTestCases;
+ public string? TmsCertValidation;
+ public string? TmsLabelsOfTestsToRun;
}
\ No newline at end of file
diff --git a/TmsRunner/Models/MessageMetadata.cs b/TmsRunner/Models/MessageMetadata.cs
index ea0ed79..a7d1804 100644
--- a/TmsRunner/Models/MessageMetadata.cs
+++ b/TmsRunner/Models/MessageMetadata.cs
@@ -4,6 +4,6 @@ namespace TmsRunner.Models;
public sealed record MessageMetadata
{
- public MessageType Type { get; set; }
- public string? Value { get; set; }
+ public MessageType Type;
+ public string? Value;
}
\ No newline at end of file
diff --git a/TmsRunner/Models/MethodMetadata.cs b/TmsRunner/Models/MethodMetadata.cs
index 4e6fdf1..5b3f351 100644
--- a/TmsRunner/Models/MethodMetadata.cs
+++ b/TmsRunner/Models/MethodMetadata.cs
@@ -2,8 +2,8 @@ namespace TmsRunner.Models;
public sealed record MethodMetadata
{
- public string? Name { get; set; }
- public string? Namespace { get; set; }
- public string? Classname { get; set; }
- public List? Attributes { get; set; }
+ public string? Name;
+ public string? Namespace;
+ public string? Classname;
+ public List? Attributes;
}
\ No newline at end of file
diff --git a/TmsRunner/Models/Step.cs b/TmsRunner/Models/Step.cs
index 1fa381a..1c8c5ad 100644
--- a/TmsRunner/Models/Step.cs
+++ b/TmsRunner/Models/Step.cs
@@ -5,16 +5,15 @@ namespace TmsRunner.Models;
public sealed class Step : StepDto
{
- public string? Result { get; set; }
- public DateTime? CompletedOn { get; set; }
- public long Duration { get; set; }
- public List Steps { get; set; } = [];
- public Step? ParentStep { get; set; }
- public int NestingLevel { get; set; }
- public List Links { get; set; } = [];
- public List Attachments { get; set; } = [];
- public string? Outcome { get; set; }
-
+ public string? Result;
+ public DateTime? CompletedOn;
+ public long Duration;
+ public List Steps = [];
+ public Step? ParentStep;
+ public int NestingLevel;
+ public List Links = [];
+ public List Attachments = [];
+ public string? Outcome;
private string? _stackTrace;
public string StackTrace()
diff --git a/TmsRunner/Models/TmsSettings.cs b/TmsRunner/Models/TmsSettings.cs
index 5ed9f63..e53bce7 100644
--- a/TmsRunner/Models/TmsSettings.cs
+++ b/TmsRunner/Models/TmsSettings.cs
@@ -1,6 +1,6 @@
namespace TmsRunner.Models;
-public sealed class TmsSettings
+public sealed record TmsSettings
{
private string? _url;
diff --git a/TmsRunner/Program.cs b/TmsRunner/Program.cs
index ce19379..8d0762c 100644
--- a/TmsRunner/Program.cs
+++ b/TmsRunner/Program.cs
@@ -25,7 +25,7 @@
namespace TmsRunner;
-public class Program
+public static class Program
{
public static async Task Main(string[] args)
{
@@ -86,6 +86,8 @@ private static IHostBuilder CreateHostBuilder(string[] args)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.MinimumLevel.Debug()
+ .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
+ .MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information)
.WriteTo.Console(LogEventLevel.Information))
.ConfigureServices((hostContext, services) =>
{
@@ -116,7 +118,7 @@ private static IHostBuilder CreateHostBuilder(string[] args)
{
BasePath = tmsSettings.Url ?? string.Empty,
ApiKeyPrefix = new Dictionary { { "Authorization", "PrivateToken" } },
- ApiKey = new Dictionary { { "Authorization", tmsSettings?.PrivateToken ?? string.Empty } }
+ ApiKey = new Dictionary { { "Authorization", tmsSettings.PrivateToken ?? string.Empty } }
};
})
.AddTransient(provider => new HttpClientHandler
@@ -145,12 +147,12 @@ private static IHostBuilder CreateHostBuilder(string[] args)
.AddTransient()
.AddTransient()
.AddTransient()
- .AddTransient(provider => new AutoResetEvent(false))
+ .AddTransient(_ => new AutoResetEvent(false))
.AddTransient()
.AddTransient()
.AddTransient(provider => new VsTestConsoleWrapper(
provider.GetRequiredService().RunnerPath ?? string.Empty,
- new ConsoleParameters { LogFilePath = Path.Combine(Directory.GetCurrentDirectory(), @"log.txt") }
+ new ConsoleParameters { LogFilePath = Path.Combine(Directory.GetCurrentDirectory(), "log.txt") }
))
.AddTransient();
});
diff --git a/TmsRunner/Services/FilterService.cs b/TmsRunner/Services/FilterService.cs
index ccb59b7..10b17e4 100644
--- a/TmsRunner/Services/FilterService.cs
+++ b/TmsRunner/Services/FilterService.cs
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
-using System.Data;
using System.Reflection;
using System.Text.RegularExpressions;
using Tms.Adapter.Attributes;
@@ -12,12 +11,12 @@ namespace TmsRunner.Services;
public sealed class FilterService(ILogger logger, Replacer replacer)
{
- private static readonly Regex _parametersRegex = new("\\((.*)\\)");
+ private static readonly Regex ParametersRegex = new("\\((.*)\\)");
// TODO: write unit tests
public List FilterTestCases(string? assemblyPath,
- IEnumerable? externalIds,
- IEnumerable testCases)
+ IReadOnlyCollection? externalIds,
+ IReadOnlyCollection testCases)
{
var testCasesToRun = new List();
var assembly = Assembly.LoadFrom(assemblyPath ?? string.Empty);
@@ -26,7 +25,7 @@ public List FilterTestCases(string? assemblyPath,
foreach (var testCase in testCases)
{
var testMethod = allTestMethods.FirstOrDefault(
- m => (m.DeclaringType!.FullName + "." + m.Name).Contains(_parametersRegex.Replace(testCase.FullyQualifiedName, string.Empty))
+ m => (m.DeclaringType!.FullName + "." + m.Name).Contains(ParametersRegex.Replace(testCase.FullyQualifiedName, string.Empty))
);
if (testMethod == null)
@@ -55,19 +54,19 @@ private string GetExternalId(MethodInfo testMethod, TestCase testCase)
if (attribute is ExternalIdAttribute externalId)
{
var parameterNames = testMethod.GetParameters().Select(x => x.Name?.ToString());
- var parameterValues = _parametersRegex.Match(testCase.DisplayName).Groups[1].Value.Split(',').Select(x => x.Replace("\"", string.Empty));
+ var parameterValues = ParametersRegex.Match(testCase.DisplayName).Groups[1].Value.Split(',').Select(x => x.Replace("\"", string.Empty));
var parameterDictionary = parameterNames
.Select(x => x ?? string.Empty)
.Zip(parameterValues, (k, v) => new { k, v })
.ToDictionary(x => x.k, x => x.v);
- return replacer.ReplaceParameters(externalId.Value, parameterDictionary!);
+ return replacer.ReplaceParameters(externalId.Value, parameterDictionary);
}
}
return (testMethod.DeclaringType!.FullName + "." + testMethod.Name).ComputeHash();
}
- public static List FilterTestCasesByLabels(AdapterConfig config, IEnumerable testCases)
+ public static List FilterTestCasesByLabels(AdapterConfig config, IReadOnlyCollection testCases)
{
var labelsToRun = config.TmsLabelsOfTestsToRun?.Split(',').Select(x => x.Trim()).ToList();
var testCasesName = testCases.Select(t => t.FullyQualifiedName);
@@ -81,8 +80,8 @@ public static List FilterTestCasesByLabels(AdapterConfig config, IEnum
foreach (var testMethod in testMethods)
{
- var fullName = testMethod?.DeclaringType?.FullName + "." + testMethod?.Name;
- var customAttributes = testMethod?.GetCustomAttributes(false) ?? [];
+ var fullName = testMethod.DeclaringType?.FullName + "." + testMethod.Name;
+ var customAttributes = testMethod.GetCustomAttributes(false);
foreach (var attribute in customAttributes)
{
diff --git a/TmsRunner/Services/ProcessorService.cs b/TmsRunner/Services/ProcessorService.cs
index 707deb7..af5b8e9 100644
--- a/TmsRunner/Services/ProcessorService.cs
+++ b/TmsRunner/Services/ProcessorService.cs
@@ -31,10 +31,10 @@ private async Task> GetStepsWithAttachmentsAsync(string? traceJson, L
{
case MessageType.TmsStep:
{
- var step = JsonSerializer.Deserialize(message?.Value ?? string.Empty);
+ var step = JsonSerializer.Deserialize(message.Value ?? string.Empty);
if (step == null)
{
- logger.LogWarning("Can not deserialize step: {Step}", message?.Value);
+ logger.LogWarning("Can not deserialize step: {Step}", message.Value);
break;
}
@@ -50,10 +50,9 @@ private async Task> GetStepsWithAttachmentsAsync(string? traceJson, L
{
var calledMethod = GetCalledMethod(step.CallerMethod);
- while (parentStep != null && calledMethod != null &&
- parentStep?.CurrentMethod != calledMethod)
+ while (parentStep != null && calledMethod != null && parentStep.CurrentMethod != calledMethod)
{
- parentStep = parentStep?.ParentStep;
+ parentStep = parentStep.ParentStep;
nestingLevel--;
}
@@ -78,11 +77,11 @@ private async Task> GetStepsWithAttachmentsAsync(string? traceJson, L
}
case MessageType.TmsStepResult:
{
- var stepResult = JsonSerializer.Deserialize(message?.Value ?? string.Empty);
+ var stepResult = JsonSerializer.Deserialize(message.Value ?? string.Empty);
if (stepResult == null)
{
- logger.LogWarning("Can not deserialize step result: {StepResult}", message?.Value ?? string.Empty);
+ logger.LogWarning("Can not deserialize step result: {StepResult}", message.Value ?? string.Empty);
break;
}
@@ -97,7 +96,7 @@ private async Task> GetStepsWithAttachmentsAsync(string? traceJson, L
}
case MessageType.TmsStepAttachmentAsText:
{
- var attachment = JsonSerializer.Deserialize(message?.Value ?? string.Empty);
+ var attachment = JsonSerializer.Deserialize(message.Value ?? string.Empty);
using var ms = new MemoryStream(Encoding.UTF8.GetBytes(attachment!.Content));
var createdAttachment =
await apiClient.UploadAttachmentAsync(Path.GetFileName(attachment.Name), ms).ConfigureAwait(false);
@@ -118,11 +117,11 @@ private async Task> GetStepsWithAttachmentsAsync(string? traceJson, L
}
case MessageType.TmsStepAttachment:
{
- var file = JsonSerializer.Deserialize(message?.Value ?? string.Empty);
+ var file = JsonSerializer.Deserialize(message.Value ?? string.Empty);
if (System.IO.File.Exists(file!.PathToFile))
{
- using var fs = new FileStream(file.PathToFile, FileMode.Open, FileAccess.Read);
+ await using var fs = new FileStream(file.PathToFile, FileMode.Open, FileAccess.Read);
var attachment = await apiClient.UploadAttachmentAsync(Path.GetFileName(file.PathToFile), fs).ConfigureAwait(false);
if (parentStep is not null)
diff --git a/TmsRunner/TmsRunner.csproj b/TmsRunner/TmsRunner.csproj
index 9d11e52..6212128 100644
--- a/TmsRunner/TmsRunner.csproj
+++ b/TmsRunner/TmsRunner.csproj
@@ -1,7 +1,7 @@
- 1.4.1
+ 1.4.2
Exe
enable
enable
diff --git a/TmsRunner/Utils/Converter.cs b/TmsRunner/Utils/Converter.cs
index 58ffee7..6025e4c 100644
--- a/TmsRunner/Utils/Converter.cs
+++ b/TmsRunner/Utils/Converter.cs
@@ -3,7 +3,7 @@
namespace TmsRunner.Utils;
-public sealed class Converter
+public static class Converter
{
public static CreateAutoTestRequest ConvertAutoTestDtoToPostModel(AutoTest autotest, string? projectId)
{
@@ -71,20 +71,20 @@ public static AutoTestResultsForTestRunModel ConvertResultToModel(AutoTestResult
return new AutoTestResultsForTestRunModel(
autoTestExternalId: autotest.ExternalId ?? string.Empty,
- outcome: Enum.Parse(autotest?.Outcome?.ToString() ?? string.Empty))
+ outcome: Enum.Parse(autotest.Outcome?.ToString() ?? string.Empty))
{
ConfigurationId = new Guid(configurationId ?? string.Empty),
Links = links ?? [],
- Message = autotest?.Message ?? string.Empty,
- Traces = autotest?.Traces ?? string.Empty,
- StartedOn = autotest?.StartedOn,
- CompletedOn = autotest?.CompletedOn,
- Duration = autotest?.Duration,
- Attachments = autotest?.Attachments?.Select(a => new AttachmentPutModel(a)).ToList() ?? [],
- Parameters = autotest?.Parameters ?? [],
- StepResults = ConvertResultStepToModel(autotest?.StepResults),
- SetupResults = ConvertResultStepToModel(autotest?.SetupResults),
- TeardownResults = ConvertResultStepToModel(autotest?.TeardownResults)
+ Message = autotest.Message ?? string.Empty,
+ Traces = autotest.Traces ?? string.Empty,
+ StartedOn = autotest.StartedOn,
+ CompletedOn = autotest.CompletedOn,
+ Duration = autotest.Duration,
+ Attachments = autotest.Attachments?.Select(a => new AttachmentPutModel(a)).ToList() ?? [],
+ Parameters = autotest.Parameters ?? [],
+ StepResults = ConvertResultStepToModel(autotest.StepResults),
+ SetupResults = ConvertResultStepToModel(autotest.SetupResults),
+ TeardownResults = ConvertResultStepToModel(autotest.TeardownResults)
};
}
@@ -104,8 +104,8 @@ private static List ConvertResultSte
Duration = s.Duration,
Attachments = s.Attachments?.Select(a => new AttachmentPutModel(a)).ToList() ?? [],
Parameters = s.Parameters ?? [],
- StepResults = ConvertResultStepToModel(s?.Steps),
- Outcome = Enum.Parse(s?.Outcome ?? string.Empty)
+ StepResults = ConvertResultStepToModel(s.Steps),
+ Outcome = Enum.Parse(s.Outcome ?? string.Empty)
}).ToList() ?? [];
}
diff --git a/TmsRunnerTests/Utils/LogParserTests.cs b/TmsRunnerTests/Utils/LogParserTests.cs
index dcb479f..cb703eb 100644
--- a/TmsRunnerTests/Utils/LogParserTests.cs
+++ b/TmsRunnerTests/Utils/LogParserTests.cs
@@ -6,7 +6,7 @@ namespace TmsRunnerTests.Utils;
[TestClass]
public class LogParserTests
{
- private static readonly string message =
+ private static readonly string Message =
MessageType.TmsParameters + ": {\"testType\":\"Simple\", \"secondParam\":\"123\"}\n" +
MessageType.TmsStep +
": {\"Guid\":\"5ebaef93-cc90-440e-adf9-d23a95a3b328\",\"StartedOn\":\"2023-03-28T10:26:53.269419Z\",\"CompletedOn\":null,\"Duration\":0,\"Title\":\"TestCleanup\",\"Description\":null,\"Instance\":\"SumTests\",\"CurrentMethod\":\"TestCleanup\",\"CallerMethod\":null,\"Args\":{},\"Result\":null,\"Steps\":[],\"ParentStep\":null,\"NestingLevel\":0,\"CallerMethodType\":2,\"CurrentMethodType\":2,\"Links\":[],\"Attachments\":[],\"Outcome\":null}\n" +
@@ -37,7 +37,7 @@ public void GetParameters_TraceWithParameters()
const string key02 = "secondParam";
const string value02 = "123";
- var parameters = LogParser.GetParameters(message);
+ var parameters = LogParser.GetParameters(Message);
Assert.IsNotNull(parameters);
Assert.AreEqual(ValueCount, parameters.Count);
@@ -66,7 +66,7 @@ public void GetMessage_TraceIsEmpty()
[TestMethod]
public void GetMessage_TraceWithMessage()
{
- var result = LogParser.GetMessage(message);
+ var result = LogParser.GetMessage(Message);
Assert.AreEqual(MessageValue, result);
}
@@ -108,7 +108,7 @@ public void GetLinks_TraceWithLinks()
Type = LinkType.Defect
};
- var result = LogParser.GetLinks(message);
+ var result = LogParser.GetLinks(Message);
Assert.IsNotNull(result);
Assert.AreEqual(ValueCount, result.Count);
diff --git a/TmsRunnerTests/Utils/ReplacerTests.cs b/TmsRunnerTests/Utils/ReplacerTests.cs
index 5e16334..9f2ccd6 100644
--- a/TmsRunnerTests/Utils/ReplacerTests.cs
+++ b/TmsRunnerTests/Utils/ReplacerTests.cs
@@ -5,9 +5,9 @@ namespace TmsRunnerTests.Utils;
[TestClass]
public class ReplacerTests
{
- private const string valueWithTags = "some string {a} {b} {c}";
+ private const string ValueWithTags = "some string {a} {b} {c}";
- private static readonly Dictionary parametersWithValue = new()
+ private static readonly Dictionary ParametersWithValue = new()
{
{ "a", "first" },
{ "b", "second" },
@@ -19,7 +19,7 @@ public void ReplaceParameters_ValueIsNull()
{
var replacer = new Replacer();
- var value = replacer.ReplaceParameters(null, parametersWithValue);
+ var value = replacer.ReplaceParameters(null, ParametersWithValue);
Assert.IsNull(value);
}
@@ -29,7 +29,7 @@ public void ReplaceParameters_ValueIsEmptyString()
{
var replacer = new Replacer();
- var value = replacer.ReplaceParameters(string.Empty, parametersWithValue);
+ var value = replacer.ReplaceParameters(string.Empty, ParametersWithValue);
Assert.AreEqual(string.Empty, value);
}
@@ -40,9 +40,9 @@ public void ReplaceParameters_ParametersIsEmpty()
var replacer = new Replacer();
var parameters = new Dictionary();
- var value = replacer.ReplaceParameters(valueWithTags, parameters);
+ var value = replacer.ReplaceParameters(ValueWithTags, parameters);
- Assert.AreEqual(valueWithTags, value);
+ Assert.AreEqual(ValueWithTags, value);
}
[TestMethod]
@@ -51,7 +51,7 @@ public void ReplaceParameters_ReplaceTags()
var replacer = new Replacer();
const string exceptedValue = "some string first second third";
- var value = replacer.ReplaceParameters(valueWithTags, parametersWithValue);
+ var value = replacer.ReplaceParameters(ValueWithTags, ParametersWithValue);
Assert.AreEqual(exceptedValue, value);
}
@@ -62,7 +62,7 @@ public void ReplaceParameters_ValueWithOutTags()
var replacer = new Replacer();
const string exceptedValue = "some string first second third";
- var value = replacer.ReplaceParameters(exceptedValue, parametersWithValue);
+ var value = replacer.ReplaceParameters(exceptedValue, ParametersWithValue);
Assert.AreEqual(exceptedValue, value);
}