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
2 changes: 1 addition & 1 deletion src/DemaConsulting.ReqStream/TraceMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ private void ExportRequirementSection(TextWriter writer, Section section, int de
/// <param name="section">The section to check.</param>
/// <param name="filterTags">The set of filter tags.</param>
/// <returns>True if the section has filtered content, false otherwise.</returns>
private bool SectionHasFilteredContent(Section section, HashSet<string>? filterTags)
private static bool SectionHasFilteredContent(Section section, HashSet<string>? filterTags)
{
// Check if section has any matching requirements
if (filterTags == null || filterTags.Count == 0)
Expand Down
176 changes: 32 additions & 144 deletions test/DemaConsulting.ReqStream.Tests/ContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,8 @@ public void Context_Create_ResultsFlag_SetsResultsFileProperty()
[TestMethod]
public void Context_Create_MissingResultsFilename_ThrowsException()
{
try
{
Context.Create(["--results"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--results requires a filename argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--results"]));
Assert.Contains("--results requires a filename argument", ex.Message);
}

/// <summary>
Expand Down Expand Up @@ -225,15 +218,8 @@ public void Context_Create_MatrixFile_SetsMatrixProperty()
[TestMethod]
public void Context_Create_UnsupportedArgument_ThrowsException()
{
try
{
Context.Create(["--unsupported"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("Unsupported argument '--unsupported'", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--unsupported"]));
Assert.Contains("Unsupported argument '--unsupported'", ex.Message);
}

/// <summary>
Expand All @@ -242,15 +228,8 @@ public void Context_Create_UnsupportedArgument_ThrowsException()
[TestMethod]
public void Context_Create_MissingLogFilename_ThrowsException()
{
try
{
Context.Create(["--log"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--log requires a filename argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--log"]));
Assert.Contains("--log requires a filename argument", ex.Message);
}

/// <summary>
Expand All @@ -259,15 +238,8 @@ public void Context_Create_MissingLogFilename_ThrowsException()
[TestMethod]
public void Context_Create_MissingReportFilename_ThrowsException()
{
try
{
Context.Create(["--report"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--report requires a filename argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--report"]));
Assert.Contains("--report requires a filename argument", ex.Message);
}

/// <summary>
Expand All @@ -276,15 +248,8 @@ public void Context_Create_MissingReportFilename_ThrowsException()
[TestMethod]
public void Context_Create_MissingMatrixFilename_ThrowsException()
{
try
{
Context.Create(["--matrix"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--matrix requires a filename argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--matrix"]));
Assert.Contains("--matrix requires a filename argument", ex.Message);
}

/// <summary>
Expand All @@ -293,15 +258,8 @@ public void Context_Create_MissingMatrixFilename_ThrowsException()
[TestMethod]
public void Context_Create_MissingReportDepth_ThrowsException()
{
try
{
Context.Create(["--report-depth"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--report-depth requires a depth argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--report-depth"]));
Assert.Contains("--report-depth requires a depth argument", ex.Message);
}

/// <summary>
Expand All @@ -310,15 +268,8 @@ public void Context_Create_MissingReportDepth_ThrowsException()
[TestMethod]
public void Context_Create_MissingMatrixDepth_ThrowsException()
{
try
{
Context.Create(["--matrix-depth"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--matrix-depth requires a depth argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--matrix-depth"]));
Assert.Contains("--matrix-depth requires a depth argument", ex.Message);
}

/// <summary>
Expand All @@ -327,35 +278,14 @@ public void Context_Create_MissingMatrixDepth_ThrowsException()
[TestMethod]
public void Context_Create_InvalidReportDepth_ThrowsException()
{
try
{
Context.Create(["--report-depth", "invalid"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--report-depth requires a positive integer", ex.Message);
}
var ex1 = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--report-depth", "invalid"]));
Assert.Contains("--report-depth requires a positive integer", ex1.Message);

try
{
Context.Create(["--report-depth", "0"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--report-depth requires a positive integer", ex.Message);
}
var ex2 = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--report-depth", "0"]));
Assert.Contains("--report-depth requires a positive integer", ex2.Message);

try
{
Context.Create(["--report-depth", "-1"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--report-depth requires a positive integer", ex.Message);
}
var ex3 = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--report-depth", "-1"]));
Assert.Contains("--report-depth requires a positive integer", ex3.Message);
}

/// <summary>
Expand All @@ -364,25 +294,11 @@ public void Context_Create_InvalidReportDepth_ThrowsException()
[TestMethod]
public void Context_Create_InvalidMatrixDepth_ThrowsException()
{
try
{
Context.Create(["--matrix-depth", "invalid"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--matrix-depth requires a positive integer", ex.Message);
}
var ex1 = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--matrix-depth", "invalid"]));
Assert.Contains("--matrix-depth requires a positive integer", ex1.Message);

try
{
Context.Create(["--matrix-depth", "0"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--matrix-depth requires a positive integer", ex.Message);
}
var ex2 = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--matrix-depth", "0"]));
Assert.Contains("--matrix-depth requires a positive integer", ex2.Message);
}

/// <summary>
Expand Down Expand Up @@ -600,15 +516,8 @@ public void Context_Create_WithTestsPattern_ExpandsGlobPattern()
[TestMethod]
public void Context_Create_MissingRequirementsPattern_ThrowsException()
{
try
{
Context.Create(["--requirements"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--requirements requires a pattern argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--requirements"]));
Assert.Contains("--requirements requires a pattern argument", ex.Message);
}

/// <summary>
Expand All @@ -617,15 +526,8 @@ public void Context_Create_MissingRequirementsPattern_ThrowsException()
[TestMethod]
public void Context_Create_MissingTestsPattern_ThrowsException()
{
try
{
Context.Create(["--tests"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--tests requires a pattern argument", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--tests"]));
Assert.Contains("--tests requires a pattern argument", ex.Message);
}

/// <summary>
Expand Down Expand Up @@ -672,15 +574,8 @@ public void Context_Create_InvalidLogPath_ThrowsException()
{
var invalidPath = Path.Combine(_testDirectory, "nonexistent", "test.log");

try
{
Context.Create(["--log", invalidPath]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("Failed to open log file", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--log", invalidPath]));
Assert.Contains("Failed to open log file", ex.Message);
}

/// <summary>
Expand Down Expand Up @@ -720,15 +615,8 @@ public void Context_Create_FilterArgumentWithSpaces_TrimsAndParsesTagsCorrectly(
[TestMethod]
public void Context_Create_FilterArgumentMissingValue_ThrowsArgumentException()
{
try
{
Context.Create(["--filter"]);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("--filter requires a comma-separated list of tags", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => Context.Create(["--filter"]));
Assert.Contains("--filter requires a comma-separated list of tags", ex.Message);
}

/// <summary>
Expand Down
22 changes: 4 additions & 18 deletions test/DemaConsulting.ReqStream.Tests/RequirementsExportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,8 @@ public void Requirements_Export_NullFilePath_ThrowsArgumentException()
File.WriteAllText(reqPath, yamlContent);
var requirements = Requirements.Read(reqPath);

try
{
requirements.Export(null!);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("File path cannot be null or empty", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => requirements.Export(null!));
Assert.Contains("File path cannot be null or empty", ex.Message);
}

/// <summary>
Expand All @@ -211,15 +204,8 @@ public void Requirements_Export_EmptyFilePath_ThrowsArgumentException()
File.WriteAllText(reqPath, yamlContent);
var requirements = Requirements.Read(reqPath);

try
{
requirements.Export(string.Empty);
Assert.Fail("Expected ArgumentException was not thrown");
}
catch (ArgumentException ex)
{
Assert.Contains("File path cannot be null or empty", ex.Message);
}
var ex = Assert.ThrowsExactly<ArgumentException>(() => requirements.Export(string.Empty));
Assert.Contains("File path cannot be null or empty", ex.Message);
}

/// <summary>
Expand Down
Loading
Loading