Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/DemaConsulting.ReqStream/.config/dotnet-tools.json

This file was deleted.

1 change: 1 addition & 0 deletions src/DemaConsulting.ReqStream/Cli/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
/// <param name="args">Command-line arguments.</param>
/// <returns>A new Context instance.</returns>
/// <exception cref="ArgumentException">Thrown when arguments are invalid.</exception>
public static Context Create(string[] args)

Check warning on line 140 in src/DemaConsulting.ReqStream/Cli/Context.cs

View workflow job for this annotation

GitHub Actions / Build / Build ubuntu-latest

Refactor this method to reduce its Cognitive Complexity from 54 to the 15 allowed.

Check warning on line 140 in src/DemaConsulting.ReqStream/Cli/Context.cs

View workflow job for this annotation

GitHub Actions / Build / Build macos-latest

Refactor this method to reduce its Cognitive Complexity from 54 to the 15 allowed.
{
// Validate input
ArgumentNullException.ThrowIfNull(args);
Expand Down Expand Up @@ -197,6 +197,7 @@
lint = true;
break;

case "--result":
case "--results":
// Ensure argument has a value
if (i >= args.Length)
Expand Down
22 changes: 22 additions & 0 deletions test/DemaConsulting.ReqStream.Tests/Cli/ContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ public void Context_Create_ResultsFlag_SetsResultsFileProperty()
Assert.AreEqual(0, context.ExitCode);
}

/// <summary>
/// Test creating a context with result flag (alias) and filename.
/// </summary>
[TestMethod]
public void Context_Create_ResultFlag_SetsResultsFileProperty()
{
using var context = Context.Create(["--result", "results.trx"]);

Assert.AreEqual("results.trx", context.ResultsFile);
Assert.AreEqual(0, context.ExitCode);
}

/// <summary>
/// Test creating a context with missing results filename.
/// </summary>
Expand All @@ -159,6 +171,16 @@ public void Context_Create_MissingResultsFilename_ThrowsException()
Assert.Contains("--results requires a filename argument", ex.Message);
}

/// <summary>
/// Test creating a context with missing result (alias) filename.
/// </summary>
[TestMethod]
public void Context_Create_MissingResultFilename_ThrowsException()
{
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--result"]));
Assert.Contains("--result requires a filename argument", ex.Message);
}

/// <summary>
/// Test creating a context with enforce flag.
/// </summary>
Expand Down
Loading