Skip to content

Conversation

@gimlichael
Copy link
Member

@gimlichael gimlichael commented Apr 11, 2025

This pull request includes significant changes to the Codebelt.Extensions.Xunit.Hosting.AspNetCore library, focusing on renaming classes and interfaces for clarity, as well as introducing new fixture classes to improve the testing infrastructure. The most important changes are grouped by theme below:

Class and Interface Renaming:

  • Renamed IMinimalWebHostFixture to IWebMinimalHostFixture to better reflect its purpose.
  • Renamed WebHostFixture to ManagedWebHostFixture to indicate it now extends ManagedHostFixture.
  • Renamed MinimalWebHostFixture to ManagedWebMinimalHostFixture to align with the new naming convention.

New Fixture Classes:

  • Added BlockingManagedWebHostFixture class to provide a synchronous, blocking implementation of ManagedWebHostFixture.
  • Introduced SelfManagedWebHostFixture class, which represents a self-managed implementation of ManagedWebHostFixture.

Method and Property Updates:

  • Updated MinimalWebHostTest class to use IWebMinimalHostFixture instead of IMinimalWebHostFixture. [1] [2]
  • Modified ManagedWebHostFixture and ManagedWebMinimalHostFixture to use AsyncHostRunnerCallback instead of HostRunnerCallback for asynchronous operations. [1] [2]

Factory Method Adjustments:

  • Updated MinimalWebHostTestFactory methods to use ManagedWebHostFixture and IWebMinimalHostFixture instead of their previous counterparts. [1] [2] [3] [4]

These changes enhance the clarity and functionality of the testing infrastructure in the Codebelt.Extensions.Xunit.Hosting.AspNetCore library.

Summary by CodeRabbit

  • New Features
    • Introduced a fresh set of managed hosting fixtures—including blocking and self-managed options—to enhance asynchronous operations and error reporting.
    • Added new extension methods for improved functionality with web host fixtures.
  • Refactor
    • Replaced legacy synchronous fixtures and outdated interface names with standardized, managed versions.
    • Updated constructors, method signatures, and documentation to align with the new fixture models.
  • Tests
    • Updated the test infrastructure to use the managed fixtures, ensuring consistent behavior and robust error logging during execution.

@gimlichael gimlichael self-assigned this Apr 11, 2025
Copilot AI review requested due to automatic review settings April 11, 2025 22:33
@coderabbitai
Copy link

coderabbitai bot commented Apr 11, 2025

Walkthrough

The pull request refactors hosting fixtures across the library and tests. Legacy blocking classes have been replaced by new managed equivalents that utilize asynchronous callbacks with cancellation tokens. Interface and class names have been standardized (e.g., renaming to ManagedWebHostFixture, IWebMinimalHostFixture, ManagedMinimalHostFixture), and factory methods have been updated accordingly. Additionally, an error handling mechanism is introduced in the Test class to capture unhandled exceptions when output is available. Test projects were updated to use the new managed fixture types.

Changes

File(s) Change Summary
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingManagedWebHostFixture.cs
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingWebHostFixture.cs
Added new BlockingManagedWebHostFixture with synchronous behavior via async callback; removed legacy BlockingWebHostFixture.
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/IWebMinimalHostFixture.cs
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTest.cs
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebMinimalHostFixtureExtensions.cs
Renamed interface from IMinimalWebHostFixture to IWebMinimalHostFixture and updated related class signatures and extension methods.
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebMinimalHostFixture.cs
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebHostFixture.cs
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebMinimalHostFixture.cs
Renamed legacy fixtures to managed variants; updated constructors and replaced synchronous callbacks with AsyncHostRunnerCallback (with cancellation tokens); added self-managed fixture implementations.
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTestFactory.cs
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostTestFactory.cs
Updated factory method signatures and default fixture instances to use new interface and managed fixture types.
src/Codebelt.Extensions.Xunit.Hosting/HostFixture.cs
src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs
src/Codebelt.Extensions.Xunit.Hosting/ManagedMinimalHostFixture.cs
Changed callbacks from synchronous Action<IHost> to asynchronous Func<IHost, CancellationToken, Task>, ensuring proper async host startup.
src/Codebelt.Extensions.Xunit.Hosting/HostTestFactory.cs
src/Codebelt.Extensions.Xunit.Hosting/MinimalHostTestFactory.cs
Updated default fixture types and documentation to reflect the use of Managed fixtures over Generic/Minimal legacy types.
src/Codebelt.Extensions.Xunit/Test.cs Introduced conditional registration of an unhandled exception event handler to log errors to provided output.
Test files (across ASP.NET Core and non–ASP.NET Core projects) Updated test class signatures and constructor parameters from legacy fixture types to their corresponding Managed variants, including fixing usages of blocking fixtures.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test
    participant F as WebHostTestFactory
    participant M as ManagedWebHostFixture
    participant H as IHost
    T->>F: Request new web host test
    F->>M: Instantiate ManagedWebHostFixture
    M->>H: Call AsyncHostRunnerCallback(Host, CancellationToken.None)
    H-->>M: Host starts asynchronously
    M-->>F: Fixture ready
    F-->>T: Web host test constructed
Loading
sequenceDiagram
    participant T as Test
    participant A as AppDomain.CurrentDomain
    participant O as Output Logger
    T->>T: Check if output != null
    T->>A: Register UnhandledException event handler
    A->>T: Unhandled exception arises
    T->>O: Log exception message
Loading

Possibly related PRs

Poem

I hopped through lines of refactored code,
Managed fixtures light my road,
As async callbacks softly chime,
Error logs dance in perfect time.
I'm a rabbit, coding with delight,
In a world where bugs take flight,
Hoppy days and code so bright!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 972ebc4 and 8fc886b.

📒 Files selected for processing (38)
  • .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt (1 hunks)
  • .nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt (1 hunks)
  • .nuget/Codebelt.Extensions.Xunit/PackageReleaseNotes.txt (1 hunks)
  • CHANGELOG.md (1 hunks)
  • Directory.Packages.props (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingManagedWebHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingWebHostFixture.cs (0 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/IWebMinimalHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/Internal/MinimalWebHostTest.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebMinimalHostFixture.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTest.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTestFactory.cs (4 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebMinimalHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostTestFactory.cs (4 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebMinimalHostFixtureExtensions.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/HostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/HostTestFactory.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/ManagedMinimalHostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/MinimalHostTestFactory.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/SelfManagedHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/SelfManagedMinimalHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit/Test.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Assets/ValidHostTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/ManagedWebHostFixtureTest.cs (4 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MinimalMvcWebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MinimalWebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MvcWebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestFactoryTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/Assets/MinimalValidHostTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/Assets/ValidHostTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/HostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/ManagedHostFixtureTest.cs (2 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/MinimalHostFixtureTest.cs (2 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/MinimalHostTestTest.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingWebHostFixture.cs

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.

Comment on lines +59 to +63
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
var exception = e.ExceptionObject as Exception;
output.WriteLine($"Unhandled exception captured: {exception?.Message}");
};
Copy link

Copilot AI Apr 11, 2025

Choose a reason for hiding this comment

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

The subscription to AppDomain.CurrentDomain.UnhandledException is added in the constructor without a corresponding unsubscription, which could lead to memory leaks or unintended behavior when the Test class is instantiated multiple times. Consider storing the delegate reference and unsubscribing it when the Test instance is disposed.

Suggested change
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
var exception = e.ExceptionObject as Exception;
output.WriteLine($"Unhandled exception captured: {exception?.Message}");
};
_unhandledExceptionHandler = (sender, e) =>
{
var exception = e.ExceptionObject as Exception;
output.WriteLine($"Unhandled exception captured: {exception?.Message}");
};
AppDomain.CurrentDomain.UnhandledException += _unhandledExceptionHandler;

Copilot uses AI. Check for mistakes.
Copy link

@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.

Actionable comments posted: 0

🧹 Nitpick comments (7)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebMinimalHostFixture.cs (1)

5-7: Correct the XML documentation reference.

The XML documentation references ManagedMinimalHostFixture, but the class actually inherits from ManagedWebMinimalHostFixture. This mismatch could confuse developers using the documentation.

-    /// Represents a self-managed implementation of the <see cref="ManagedMinimalHostFixture"/> class.
+    /// Represents a self-managed implementation of the <see cref="ManagedWebMinimalHostFixture"/> class.
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingManagedWebHostFixture.cs (2)

6-9: Consider including more details in the documentation.

While the documentation correctly describes the purpose of the class, it could be enhanced by explaining the behavior of the blocking implementation and how it differs from non-blocking implementations.

    /// <summary>
    /// Extends the default implementation of the <see cref="IWebHostFixture"/> interface to be synchronous e.g., blocking where exceptions can be captured.
+    /// Unlike asynchronous implementations, this class starts the host synchronously and is useful for testing scenarios where blocking behavior is required.
    /// </summary>

17-22: Consider adding cancellation token handling.

The current implementation starts the host but doesn't utilize the provided cancellation token. Consider handling the cancellation token for more robust behavior, especially in test scenarios where cancellation might be important.

-            AsyncHostRunnerCallback = (host, _) =>
+            AsyncHostRunnerCallback = (host, cancellationToken) =>
             {
                 host.Start();
+                cancellationToken.Register(() => 
+                {
+                    try { host.StopAsync().GetAwaiter().GetResult(); }
+                    catch { /* Ignore exceptions during forced stop */ }
+                });
                 return Task.CompletedTask;
             };
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTestFactory.cs (4)

24-29: Fix documentation to match parameter type

The XML documentation comment refers to IWebHostFixture and ManagedWebHostFixture, but the actual parameter type is IWebMinimalHostFixture. The documentation should be updated to match the actual type.

-        /// <param name="hostFixture">An optional <see cref="IWebHostFixture"/> implementation to use instead of the default <see cref="ManagedWebHostFixture"/> instance.</param>
+        /// <param name="hostFixture">An optional <see cref="IWebMinimalHostFixture"/> implementation to use instead of the default <see cref="ManagedWebMinimalHostFixture"/> instance.</param>

37-42: Fix documentation to match parameter type

Similar to the previous comment, the XML documentation should be updated to match the actual parameter type.

-        /// <param name="hostFixture">An optional <see cref="IWebHostFixture"/> implementation to use instead of the default <see cref="ManagedWebHostFixture"/> instance.</param>
+        /// <param name="hostFixture">An optional <see cref="IWebMinimalHostFixture"/> implementation to use instead of the default <see cref="ManagedWebMinimalHostFixture"/> instance.</param>

51-57: Fix documentation to match parameter type

Documentation comment should reference the correct interface and implementation types.

-        /// <param name="hostFixture">An optional <see cref="IWebHostFixture"/> implementation to use instead of the default <see cref="ManagedWebHostFixture"/> instance.</param>
+        /// <param name="hostFixture">An optional <see cref="IWebMinimalHostFixture"/> implementation to use instead of the default <see cref="ManagedWebMinimalHostFixture"/> instance.</param>

66-72: Fix documentation to match parameter type

Documentation comment should reference the correct interface and implementation types.

-        /// <param name="hostFixture">An optional <see cref="IWebHostFixture"/> implementation to use instead of the default <see cref="ManagedWebHostFixture"/> instance.</param>
+        /// <param name="hostFixture">An optional <see cref="IWebMinimalHostFixture"/> implementation to use instead of the default <see cref="ManagedWebMinimalHostFixture"/> instance.</param>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 972ebc4 and ebad8fb.

📒 Files selected for processing (33)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingManagedWebHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingWebHostFixture.cs (0 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/IWebMinimalHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/Internal/MinimalWebHostTest.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebMinimalHostFixture.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTest.cs (2 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTestFactory.cs (4 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebMinimalHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostTestFactory.cs (4 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebMinimalHostFixtureExtensions.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/HostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/HostTestFactory.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/ManagedMinimalHostFixture.cs (3 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/MinimalHostTestFactory.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/SelfManagedHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit.Hosting/SelfManagedMinimalHostFixture.cs (1 hunks)
  • src/Codebelt.Extensions.Xunit/Test.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Assets/ValidHostTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/ManagedWebHostFixtureTest.cs (4 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MinimalMvcWebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MinimalWebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MvcWebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestFactoryTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/Assets/MinimalValidHostTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/Assets/ValidHostTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/HostTestTest.cs (1 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/ManagedHostFixtureTest.cs (2 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/MinimalHostFixtureTest.cs (2 hunks)
  • test/Codebelt.Extensions.Xunit.Hosting.Tests/MinimalHostTestTest.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/BlockingWebHostFixture.cs
🧰 Additional context used
🧬 Code Graph Analysis (8)
test/Codebelt.Extensions.Xunit.Hosting.Tests/HostTestTest.cs (2)
src/Codebelt.Extensions.Xunit.Hosting/HostTest.cs (5)
  • HostTest (16-55)
  • HostTest (23-25)
  • HostTest (65-118)
  • HostTest (76-78)
  • HostTest (90-103)
src/Codebelt.Extensions.Xunit.Hosting/Internal/HostTest.cs (3)
  • HostTest (7-57)
  • HostTest (14-19)
  • HostTest (21-26)
test/Codebelt.Extensions.Xunit.Hosting.Tests/Assets/MinimalValidHostTest.cs (2)
src/Codebelt.Extensions.Xunit.Hosting/Internal/MinimalHostTest.cs (3)
  • MinimalHostTest (7-52)
  • MinimalHostTest (14-19)
  • MinimalHostTest (21-26)
src/Codebelt.Extensions.Xunit.Hosting/MinimalHostTest.cs (5)
  • MinimalHostTest (12-31)
  • MinimalHostTest (19-21)
  • MinimalHostTest (40-78)
  • MinimalHostTest (51-53)
  • MinimalHostTest (65-77)
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestTest.cs (2)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostTest.cs (3)
  • WebHostTest (14-61)
  • WebHostTest (22-24)
  • WebHostTest (33-48)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/Internal/WebHostTest.cs (3)
  • WebHostTest (8-76)
  • WebHostTest (17-23)
  • WebHostTest (25-31)
test/Codebelt.Extensions.Xunit.Hosting.Tests/MinimalHostTestTest.cs (2)
src/Codebelt.Extensions.Xunit.Hosting/Internal/MinimalHostTest.cs (3)
  • MinimalHostTest (7-52)
  • MinimalHostTest (14-19)
  • MinimalHostTest (21-26)
src/Codebelt.Extensions.Xunit.Hosting/MinimalHostTest.cs (5)
  • MinimalHostTest (12-31)
  • MinimalHostTest (19-21)
  • MinimalHostTest (40-78)
  • MinimalHostTest (51-53)
  • MinimalHostTest (65-77)
src/Codebelt.Extensions.Xunit.Hosting/MinimalHostTestFactory.cs (3)
src/Codebelt.Extensions.Xunit.Hosting/HostTestFactory.cs (2)
  • IHostTest (19-22)
  • IHostTest (31-34)
src/Codebelt.Extensions.Xunit.Hosting/Internal/MinimalHostTest.cs (3)
  • MinimalHostTest (7-52)
  • MinimalHostTest (14-19)
  • MinimalHostTest (21-26)
src/Codebelt.Extensions.Xunit.Hosting/ManagedMinimalHostFixture.cs (2)
  • ManagedMinimalHostFixture (13-61)
  • ManagedMinimalHostFixture (18-20)
test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MinimalWebHostTestTest.cs (2)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTest.cs (3)
  • MinimalWebHostTest (17-66)
  • MinimalWebHostTest (25-27)
  • MinimalWebHostTest (39-53)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/Internal/MinimalWebHostTest.cs (3)
  • MinimalWebHostTest (8-71)
  • MinimalWebHostTest (17-23)
  • MinimalWebHostTest (25-31)
src/Codebelt.Extensions.Xunit.Hosting/HostTestFactory.cs (2)
src/Codebelt.Extensions.Xunit.Hosting/Internal/HostTest.cs (3)
  • HostTest (7-57)
  • HostTest (14-19)
  • HostTest (21-26)
src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs (2)
  • ManagedHostFixture (16-93)
  • ManagedHostFixture (21-23)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/Internal/MinimalWebHostTest.cs (1)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTest.cs (3)
  • MinimalWebHostTest (17-66)
  • MinimalWebHostTest (25-27)
  • MinimalWebHostTest (39-53)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: 🧪 Test (windows-2022, Release)
  • GitHub Check: 🧪 Test (windows-2022, Debug)
  • GitHub Check: 🧪 Test (ubuntu-22.04, Debug)
  • GitHub Check: 🧪 Test (ubuntu-22.04, Release)
  • GitHub Check: 📦 Pack (Release)
  • GitHub Check: 📦 Pack (Debug)
🔇 Additional comments (69)
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/IWebMinimalHostFixture.cs (1)

11-11: Interface renaming looks good

The renaming from IMinimalWebHostFixture to IWebMinimalHostFixture improves naming consistency across the library as outlined in the PR objectives. This change maintains the same functionality while making the interface naming more consistent with the overall architecture.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebHostFixture.cs (1)

1-21: Well-implemented self-managed fixture implementation

This new class correctly implements a self-managed version of ManagedWebHostFixture with appropriate documentation. The no-op async callback implementation allows the class to fulfill its purpose of being self-managed.

src/Codebelt.Extensions.Xunit.Hosting/SelfManagedMinimalHostFixture.cs (1)

1-21: Consistent implementation with web host counterpart

This implementation follows the same pattern as SelfManagedWebHostFixture but for the minimal host variant. The class is well-documented and correctly implements the self-managed pattern with the no-op async callback.

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestFactoryTest.cs (1)

50-50: Correctly updated to use new fixture class

The test has been properly updated to use the new BlockingManagedWebHostFixture instead of the previous BlockingWebHostFixture, aligning with the class renaming objectives of the PR.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/SelfManagedWebMinimalHostFixture.cs (1)

8-20: Implementation looks good.

This class provides a clean implementation of a self-managed host fixture by setting the AsyncHostRunnerCallback to a no-op delegate, which aligns with the PR's objective of enhancing the testing infrastructure.

src/Codebelt.Extensions.Xunit.Hosting/SelfManagedHostFixture.cs (1)

1-21: Well-structured implementation.

The class follows a consistent pattern with other self-managed fixtures in the codebase, providing a clean implementation by setting the AsyncHostRunnerCallback to a no-op delegate. The documentation is clear and accurate.

src/Codebelt.Extensions.Xunit/Test.cs (1)

57-63: Good error handling enhancement.

Adding a handler for unhandled exceptions improves the test framework's ability to capture and report errors. This enhancement aligns with best practices for robust test frameworks.

However, consider using a more descriptive message that includes the exception type and stack trace for better debugging:

-                output.WriteLine($"Unhandled exception captured: {exception?.Message}");
+                output.WriteLine($"Unhandled exception captured: {exception?.GetType().Name}: {exception?.Message}");
+                output.WriteLine($"Stack trace: {exception?.StackTrace}");
test/Codebelt.Extensions.Xunit.Hosting.Tests/Assets/ValidHostTest.cs (1)

8-10: Update aligns with the new naming conventions

The change from GenericHostFixture to ManagedHostFixture aligns with the PR objective of improving naming consistency across fixtures. This update correctly reflects the broader architectural shift to managed hosting fixtures in the library.

src/Codebelt.Extensions.Xunit.Hosting/ManagedMinimalHostFixture.cs (3)

12-13: Class renaming improves clarity

The class renaming from MinimalHostFixture to ManagedMinimalHostFixture along with updated documentation improves naming consistency across the codebase. The "Managed" prefix better describes the fixture's responsibility and aligns with the broader architectural refactoring.


16-18: Documentation updated correctly

The XML documentation has been properly updated to reference the new class name, maintaining code documentation quality.


2-2: Upgraded to asynchronous pattern with cancellation support

The implementation now uses AsyncHostRunnerCallback with a cancellation token instead of the synchronous HostRunnerCallback. This is an important modernization that:

  1. Follows .NET best practices for asynchronous operations
  2. Enables proper cancellation support
  3. Provides better resource cleanup during shutdown

The addition of the System.Threading namespace supports this enhancement.

Also applies to: 53-53

test/Codebelt.Extensions.Xunit.Hosting.Tests/HostTestTest.cs (1)

16-16: Updated test class to use ManagedHostFixture

The test class has been correctly updated to extend HostTest<ManagedHostFixture> instead of HostTest<GenericHostFixture> and its constructor parameter type has been correspondingly updated. This change maintains test coverage while aligning with the new fixture naming convention.

Also applies to: 23-23

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/Assets/ValidHostTest.cs (1)

6-9: Updated to use ManagedWebHostFixture

The test class has been properly updated to use ManagedWebHostFixture instead of WebHostFixture. This change aligns with the PR objectives for consistent naming conventions across the library, making the relationship between different fixture types more explicit and clearer.

src/Codebelt.Extensions.Xunit.Hosting/ManagedHostFixture.cs (3)

4-4: Addition of Thread support aligns with async hosting changes

The addition of the Threading namespace supports the later change to use async host runner callbacks with cancellation tokens.


16-16: Appropriate class renaming from GenericHostFixture to ManagedHostFixture

This rename aligns with the PR objective to improve naming clarity across hosting fixtures. Documentation has been properly updated to reflect the new class name.

Also applies to: 19-19, 21-21


79-79: Transition to async host runner with cancellation support

The change from HostRunnerCallback(Host) to AsyncHostRunnerCallback(Host, CancellationToken.None) enables proper async operation with cancellation support, which is an improvement for resource management.

test/Codebelt.Extensions.Xunit.Hosting.Tests/Assets/MinimalValidHostTest.cs (1)

7-10: Consistent fixture type update in test class

The test class has been properly updated to use ManagedMinimalHostFixture instead of MinimalHostFixture, maintaining consistency with the broader naming changes in the PR.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebMinimalHostFixtureExtensions.cs (4)

4-5: Class and interface naming improved for clarity

The class has been renamed from MinimalWebHostFixtureExtensions to WebMinimalHostFixtureExtensions and references to IMinimalWebHostFixture have been updated to IWebMinimalHostFixture, aligning with the PR objectives for improved naming clarity.

Also applies to: 6-7


9-13: Documentation properly updated for interface rename

The XML documentation has been correctly updated to reference the renamed interface IWebMinimalHostFixture throughout.


16-17: Updated XML documentation for interface references

The XML comment has been updated to reference IWebMinimalHostFixture while preserving references to other interfaces.


18-22: Method signature updated while preserving functionality

The method signature has been updated to use IWebMinimalHostFixture while the internal implementation logic remains unchanged, ensuring backward compatibility with existing behavior.

test/Codebelt.Extensions.Xunit.Hosting.Tests/ManagedHostFixtureTest.cs (3)

4-6: Additional namespace imports support enhanced fixture functionality

The added imports for DI, Hosting, and Logging support the expanded functionality of the managed host fixtures.


12-14: Test class properly renamed with updated fixture references

The test class has been renamed from GenericHostFixtureTest to ManagedHostFixtureTest with all fixture references updated accordingly, maintaining consistency with the broader naming changes in the PR.

Also applies to: 16-19


30-31: Test case updated to use renamed fixture type

The invalid host test case has been properly updated to use ManagedHostFixture instead of GenericHostFixture, ensuring tests continue to work with the renamed types.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTest.cs (1)

12-12: Interface renaming correctly implemented.

The renaming from IMinimalWebHostFixture to IWebMinimalHostFixture has been consistently applied across the class declaration and all XML documentation. This change aligns with the PR objectives for naming consistency.

Also applies to: 17-17, 22-22, 33-33

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/ManagedWebHostFixtureTest.cs (2)

9-11: Class renaming correctly implemented.

The test class has been properly renamed from WebHostFixtureTest to ManagedWebHostFixtureTest, including its constructor, which aligns with the renamed fixture class.


19-20: All fixture references properly updated.

All instances of WebHostFixture have been correctly updated to ManagedWebHostFixture, including test setup and the InvalidHostTest<T> generic parameter.

Also applies to: 29-30, 40-41, 54-55

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/WebHostTestTest.cs (1)

17-17: Generic type parameter and constructor parameter correctly updated.

The class now correctly extends WebHostTest<ManagedWebHostFixture> instead of WebHostTest<WebHostFixture>, and the constructor parameter has been updated accordingly. This change maintains consistency with the renamed fixture.

Also applies to: 22-22

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebHostFixture.cs (3)

3-3: Added necessary namespace for CancellationToken.

The System.Threading namespace has been added to support the CancellationToken parameter used in AsyncHostRunnerCallback.


17-19: Class renamed and inheritance updated.

The class has been properly renamed from WebHostFixture to ManagedWebHostFixture and now extends ManagedHostFixture instead of a previous base class. The XML documentation has been updated accordingly.

Also applies to: 22-24


95-95: Updated to use asynchronous callback with cancellation token.

The implementation now uses AsyncHostRunnerCallback with a CancellationToken parameter instead of the previous synchronous callback. This aligns with the PR objective of updating fixtures to use asynchronous operations.

test/Codebelt.Extensions.Xunit.Hosting.Tests/MinimalHostTestTest.cs (2)

16-16: Appropriate class name update.

The base class has been updated from MinimalHostTest<MinimalHostFixture> to MinimalHostTest<ManagedMinimalHostFixture> to align with the library's new naming convention. This change is consistent with the PR's objective of improving clarity through better naming.


23-23: Constructor parameter update matches class inheritance change.

The constructor parameter has been updated from MinimalHostFixture to ManagedMinimalHostFixture to match the updated base class. This ensures consistency in the type system.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ManagedWebMinimalHostFixture.cs (4)

2-2: Required namespace for CancellationToken.

The System.Threading namespace has been added to support the use of CancellationToken in the updated host runner callback.


10-15: Updated class and interface names in documentation and implementation.

The class and interface names have been updated in both the documentation comments and class declaration:

  • Interface referenced in documentation changed from IMinimalWebHostFixture to IWebMinimalHostFixture
  • Base class reference updated to ManagedMinimalHostFixture
  • Class name changed from MinimalWebHostFixture to ManagedWebMinimalHostFixture

These changes align with the PR's objective of improving naming consistency across the library.


18-20: Constructor name updated to match class name.

The constructor name has been updated from MinimalWebHostFixture to ManagedWebMinimalHostFixture to match the new class name.


62-62: Updated to use asynchronous host runner with cancellation token.

The method call has been updated from HostRunnerCallback(Host) to AsyncHostRunnerCallback(Host, CancellationToken.None) to use the new asynchronous callback pattern with cancellation support.

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MinimalWebHostTestTest.cs (2)

18-18: Updated base class to use new managed fixture type.

The base class has been updated from MinimalWebHostTest<MinimalWebHostFixture> to MinimalWebHostTest<ManagedWebMinimalHostFixture> to use the renamed fixture type. This change is consistent with the PR's objective of improving naming clarity.


23-23: Constructor parameter updated to use renamed fixture type.

The constructor parameter has been updated from MinimalWebHostFixture to ManagedWebMinimalHostFixture to match the updated base class type parameter.

src/Codebelt.Extensions.Xunit.Hosting/HostFixture.cs (3)

2-2: Added threading namespace for CancellationToken support.

The System.Threading namespace has been added to support the use of CancellationToken in the updated asynchronous host runner callback.


17-32: Improved host runner implementation with asynchronous support.

The host runner callback has been enhanced:

  1. Changed from Action<IHost> to Func<IHost, CancellationToken, Task> to support asynchronous operations
  2. Added cancellation token support for proper cancellation handling
  3. Implemented context-aware execution strategy to avoid deadlocks:
    • Uses direct await when no SynchronizationContext exists
    • Uses Task.Run when a SynchronizationContext is present

This is a significant improvement that makes the host runner more robust and follows asynchronous best practices.


69-73: Renamed property to reflect its asynchronous nature.

The property has been aptly renamed from HostRunnerCallback to AsyncHostRunnerCallback to clearly indicate its asynchronous behavior. The getter and setter have been updated to work with the new Func<IHost, CancellationToken, Task> delegate type.

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MvcWebHostTestTest.cs (3)

13-13: Type update aligns with the new naming convention.

The change from WebHostTest<WebHostFixture> to WebHostTest<ManagedWebHostFixture> correctly implements the renaming convention described in the PR objectives. This update is consistent with the library-wide rename of WebHostFixture to ManagedWebHostFixture.


15-15: Field type update is consistent with the class declaration.

The _hostFixture field has been properly updated to use the ManagedWebHostFixture type, maintaining consistency with the class declaration.


18-18: Constructor parameter type correctly updated.

The constructor parameter has been appropriately updated to accept a ManagedWebHostFixture instance, aligning with both the class declaration and field type changes.

test/Codebelt.Extensions.Xunit.Hosting.AspNetCore.Tests/MinimalMvcWebHostTestTest.cs (3)

14-14: Base class update aligns with the PR objectives.

The change from MinimalWebHostTest<MinimalWebHostFixture> to MinimalWebHostTest<ManagedWebMinimalHostFixture> correctly implements the renaming convention described in the PR objectives, where MinimalWebHostFixture has been renamed to ManagedWebMinimalHostFixture.


16-16: Field type update is consistent.

The _hostFixture field type has been properly updated to use the ManagedWebMinimalHostFixture type, maintaining consistency with the class declaration.


19-19: Constructor parameter type correctly updated.

The constructor parameter has been appropriately updated to accept a ManagedWebMinimalHostFixture instance, aligning with both the class declaration and field type changes.

src/Codebelt.Extensions.Xunit.Hosting/HostTestFactory.cs (4)

17-17: Documentation updated to reflect the new default fixture type.

The XML documentation for the hostFixture parameter has been correctly updated to reference ManagedHostFixture as the default implementation, aligning with the implementation change in line 21.


21-21: Default fixture instantiation updated.

The default fixture instantiation has been updated from GenericHostFixture to ManagedHostFixture, consistent with the PR's naming convention changes. This ensures that all new tests created through this factory will use the new managed fixture implementation.


29-29: Documentation updated for consistency.

The XML documentation in the CreateWithHostBuilderContext method has been correctly updated to match the documentation in the Create method, maintaining consistency across the API.


33-33: Default fixture instantiation updated in second method.

The default fixture instantiation in the CreateWithHostBuilderContext method has also been updated to use ManagedHostFixture, ensuring consistent behavior between both factory methods.

test/Codebelt.Extensions.Xunit.Hosting.Tests/MinimalHostFixtureTest.cs (3)

11-11: Field type updated to use the new managed fixture.

The _hostFixture field type has been correctly updated from MinimalHostFixture to ManagedMinimalHostFixture, aligning with the PR's naming convention changes.


15-15: Object instantiation updated to match the new type.

The instantiation of the fixture has been updated to create a ManagedMinimalHostFixture instance, matching the field type declared in line 11.


27-27: Test case updated to use the new fixture types.

The test has been updated to use InvalidHostTest<ManagedHostFixture> with a ManagedHostFixture instance, ensuring compatibility with the new fixture naming convention throughout the test suite.

src/Codebelt.Extensions.Xunit.Hosting/MinimalHostTestFactory.cs (2)

17-22: LGTM: Update to use ManagedMinimalHostFixture

The change to use ManagedMinimalHostFixture instead of MinimalHostFixture is consistent with the PR objectives of improving naming clarity throughout the library.


29-34: LGTM: Update to use ManagedMinimalHostFixture

The change to use ManagedMinimalHostFixture in the CreateWithHostBuilderContext method is consistent with the renaming pattern applied throughout the PR.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/Internal/MinimalWebHostTest.cs (4)

8-8: LGTM: Interface rename from IMinimalWebHostFixture to IWebMinimalHostFixture

This change correctly updates the base class generic type parameter to use the renamed interface IWebMinimalHostFixture, which aligns with the PR objectives.


17-18: LGTM: Parameter type updated to IWebMinimalHostFixture

Parameter type has been properly updated to use the renamed interface.


25-26: LGTM: Parameter type updated to IWebMinimalHostFixture

Parameter type has been properly updated in the overloaded constructor.


33-34: LGTM: Parameter type updated in InitializeHostFixture method

The method parameter type has been properly updated to use the renamed interface.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebHostTestFactory.cs (4)

24-29: LGTM: Update to use ManagedWebHostFixture

The change to use ManagedWebHostFixture instead of WebHostFixture is consistent with the PR objectives. Both the XML documentation and implementation have been properly updated.


37-42: LGTM: Update to use ManagedWebHostFixture in CreateWithHostBuilderContext

Documentation and implementation correctly updated to use the renamed class.


51-57: LGTM: Update to use ManagedWebHostFixture in RunAsync

Documentation updated properly for the RunAsync method.


66-72: LGTM: Update to use ManagedWebHostFixture in RunWithHostBuilderContextAsync

Documentation updated properly for the RunWithHostBuilderContextAsync method.

src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTestFactory.cs (4)

26-29: LGTM: Parameter type and implementation updated

The parameter type has been properly updated to use IWebMinimalHostFixture and the implementation uses ManagedWebMinimalHostFixture, which aligns with the PR objectives.


39-42: LGTM: Parameter type and implementation updated

Properly updated parameter type and implementation in the CreateWithHostBuilderContext method.


53-57: LGTM: Parameter type updated in RunAsync

Parameter type has been properly updated to use the renamed interface.


68-72: LGTM: Parameter type updated in RunWithHostBuilderContextAsync

Parameter type has been properly updated to use the renamed interface.

@codecov
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 67.18750% with 21 lines in your changes missing coverage. Please review.

Project coverage is 92.26%. Comparing base (972ebc4) to head (8fc886b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...it.Hosting.AspNetCore/SelfManagedWebHostFixture.cs 0.00% 4 Missing ⚠️
...ing.AspNetCore/SelfManagedWebMinimalHostFixture.cs 0.00% 4 Missing ⚠️
...Extensions.Xunit.Hosting/SelfManagedHostFixture.cs 0.00% 4 Missing ⚠️
...ons.Xunit.Hosting/SelfManagedMinimalHostFixture.cs 0.00% 4 Missing ⚠️
....Hosting.AspNetCore/Internal/MinimalWebHostTest.cs 0.00% 0 Missing and 2 partials ⚠️
...osting.AspNetCore/BlockingManagedWebHostFixture.cs 87.50% 1 Missing ⚠️
...c/Codebelt.Extensions.Xunit.Hosting/HostFixture.cs 93.75% 0 Missing and 1 partial ⚠️
src/Codebelt.Extensions.Xunit/Test.cs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
- Coverage   93.97%   92.26%   -1.71%     
==========================================
  Files          44       48       +4     
  Lines         896      931      +35     
  Branches      123      125       +2     
==========================================
+ Hits          842      859      +17     
- Misses         44       62      +18     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

@gimlichael gimlichael merged commit 4e11b2c into main Apr 12, 2025
19 of 21 checks passed
@gimlichael gimlichael deleted the v10.0.0/naming-consistency branch April 12, 2025 00:23
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.

2 participants