Skip to content

chore: resolve xunit warnings BED-8243#303

Merged
lrfalslev merged 3 commits into
v4from
lfalslev/bed-8243
May 21, 2026
Merged

chore: resolve xunit warnings BED-8243#303
lrfalslev merged 3 commits into
v4from
lfalslev/bed-8243

Conversation

@lrfalslev
Copy link
Copy Markdown
Contributor

@lrfalslev lrfalslev commented May 8, 2026

Description

xunit is warning over some syntax issues in tests, this pr updates the tests to resolve the warnings and clean up build output.

Motivation and Context

This PR addresses: BED-8243

How Has This Been Tested?

Ran dotnet build and dotnet test

Screenshots (if appropriate):

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Summary by CodeRabbit

  • Tests
    • Updated unit tests to adopt proper async/await signatures and awaiting for reliable async execution.
    • Improved assertion order and clarity in several tests to make failures clearer and more consistent.
    • Adjusted concurrency and collection validation approaches to strengthen test robustness and correctness.
    • Removed unnecessary test-level dependencies to streamline the test suite.

Review Change Stack

@lrfalslev lrfalslev self-assigned this May 8, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc51afcc-7cb9-4765-9e53-4480b0ae80f6

📥 Commits

Reviewing files that changed from the base of the PR and between 84bb2eb and 8ee4cd1.

📒 Files selected for processing (2)
  • test/unit/LDAPFilterTest.cs
  • test/unit/LdapPropertyTests.cs

Walkthrough

Seven unit test files are refactored to improve test infrastructure and conform to xUnit best practices. Changes include converting async void test methods to async Task, correcting assertion parameter order from (actual, expected) to (expected, actual), replacing blocking synchronization with async patterns, improving assertion expressions, and removing unused dependencies.

Changes

Test Best Practices

Layer / File(s) Summary
Async Test Method Signatures
test/unit/DefaultLabelValuesCacheTests.cs, test/unit/LDAPUtilsTest.cs, test/unit/LdapPropertyTests.cs, test/unit/SPNProcessorsTest.cs
Async test methods converted from async void to async Task to enable proper async/await semantics in xUnit test runners. Affects multiple test method signatures across these files.
Assertion and Synchronization Patterns
test/unit/ACLProcessorTest.cs, test/unit/DefaultLabelValuesCacheTests.cs, test/unit/LDAPFilterTest.cs
Assert.Equal parameter order corrected to (expected, actual) across many assertions in ACLProcessorTest; blocking Task.WaitAll() replaced with await Task.WhenAll() in DefaultLabelValuesCacheTests; Assert.Single predicate usage applied in LDAPFilterTest.
Test Infrastructure Cleanup
test/unit/LDAPUtilsTest.cs, test/unit/MetricAggregatorTests.cs
Removed unused System.DirectoryServices.ActiveDirectory import from LDAPUtilsTest; removed ITestOutputHelper constructor parameter and its Xunit.Abstractions import from MetricAggregatorTests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • ktstrader
  • definitelynotagoblin

Poem

🐰 I hopped through tests both day and night,

Awaiting tasks to finish right,
Assertions lined in tidy rows,
Unused imports gone like crows,
A cleaner suite — my whiskers bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'chore: resolve xunit warnings BED-8243' directly and clearly summarizes the main change—resolving xUnit warnings referenced by ticket BED-8243 across multiple test files.
Description check ✅ Passed The PR description follows the template with all critical sections completed: describes the xUnit warnings fix, provides Jira ticket reference (BED-8243), documents testing methodology (dotnet build and dotnet test), correctly marks as 'Chore', and confirms checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lfalslev/bed-8243

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/unit/LDAPFilterTest.cs (1)

89-106: ⚡ Quick win

Consider materializing filters to avoid multiple enumerations.

filters is IEnumerable<string> and is enumerated four times: once in the foreach (lines 95–100), twice in the two Assert.Single calls (lines 103–104), and once in filters.Count() (line 106). If GetFilterList() returns a deferred/lazy sequence, the query is re-evaluated each time. Materializing up front removes the ambiguity:

♻️ Proposed refactor
-            IEnumerable<string> filters = test.GetFilterList();
+            IReadOnlyList<string> filters = test.GetFilterList().ToList();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/unit/LDAPFilterTest.cs` around lines 89 - 106, The test re-enumerates
the deferred IEnumerable<string> returned by test.GetFilterList() multiple times
(in the foreach, two Assert.Single calls, and Count()), which can re-evaluate
the sequence or produce different results; materialize the sequence immediately
by assigning filters = test.GetFilterList().ToList() (ensure System.Linq is
available) and then run the foreach, Assert.Single checks (using the List), and
Assert.Equal(2, filters.Count) against the concrete list to avoid multiple
enumerations and side effects; references: test.GetFilterList(), variable
filters, mandatoryFilter1, mandatoryFilter2, userFilter, computerFilter.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/unit/LDAPFilterTest.cs`:
- Around line 89-106: The test re-enumerates the deferred IEnumerable<string>
returned by test.GetFilterList() multiple times (in the foreach, two
Assert.Single calls, and Count()), which can re-evaluate the sequence or produce
different results; materialize the sequence immediately by assigning filters =
test.GetFilterList().ToList() (ensure System.Linq is available) and then run the
foreach, Assert.Single checks (using the List), and Assert.Equal(2,
filters.Count) against the concrete list to avoid multiple enumerations and side
effects; references: test.GetFilterList(), variable filters, mandatoryFilter1,
mandatoryFilter2, userFilter, computerFilter.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc84b48b-ac84-4f72-8a7e-ff05090782f0

📥 Commits

Reviewing files that changed from the base of the PR and between 4a7b874 and 84bb2eb.

📒 Files selected for processing (7)
  • test/unit/ACLProcessorTest.cs
  • test/unit/DefaultLabelValuesCacheTests.cs
  • test/unit/LDAPFilterTest.cs
  • test/unit/LDAPUtilsTest.cs
  • test/unit/LdapPropertyTests.cs
  • test/unit/MetricAggregatorTests.cs
  • test/unit/SPNProcessorsTest.cs

@lrfalslev lrfalslev merged commit 8a4583f into v4 May 21, 2026
3 of 4 checks passed
@lrfalslev lrfalslev deleted the lfalslev/bed-8243 branch May 21, 2026 16:44
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants