Skip to content

chore: resolve xunit warnings BED-8243#303

Open
lrfalslev wants to merge 2 commits intov4from
lfalslev/bed-8243
Open

chore: resolve xunit warnings BED-8243#303
lrfalslev wants to merge 2 commits intov4from
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 use proper async/await patterns for improved test runner compatibility and execution reliability.
    • Refactored test assertion approaches and synchronization mechanisms in concurrency and filtering tests for enhanced validation robustness.
    • Optimized test suite dependencies to streamline structure.

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

coderabbitai Bot commented May 8, 2026

Review Change Stack

Warning

Rate limit exceeded

@lrfalslev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 8 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 15f098ad-7747-44fb-8aca-745b6d4e7b8c

📥 Commits

Reviewing files that changed from the base of the PR and between 84bb2eb and 9b276ee.

📒 Files selected for processing (1)
  • test/unit/LDAPFilterTest.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 fourteen test method signatures across four 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 twenty-two test assertions in ACLProcessorTest; blocking Task.WaitAll() replaced with await Task.WhenAll() in DefaultLabelValuesCacheTests; Assert.Single predicate pattern applied in LDAPFilterTest.
Test Infrastructure Cleanup
test/unit/LDAPUtilsTest.cs, test/unit/MetricAggregatorTests.cs
Unused System.DirectoryServices.ActiveDirectory import removed from LDAPUtilsTest; ITestOutputHelper constructor dependency and Xunit.Abstractions import removed from MetricAggregatorTests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Async tests now await with grace,
Assertions march in proper place,
Dependencies cast aside so clean,
The finest test suite ever seen!
xUnit cheers our hoppy friend,
Best practices we now defend!

🚥 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 title accurately summarizes the main objective: resolving xUnit warnings and referencing the specific ticket (BED-8243) related to the changes.
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.
Description check ✅ Passed The PR description covers the required sections with clear motivation (resolving xUnit warnings) and testing approach (dotnet build and test), though testing details are minimal.

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

✨ Finishing Touches
🧪 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant