-
Notifications
You must be signed in to change notification settings - Fork 1
V10.0.0/naming consistency #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…st being started per default)
…b host being started per default)
WalkthroughThe 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
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
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
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (38)
💤 Files with no reviewable changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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.
| AppDomain.CurrentDomain.UnhandledException += (sender, e) => | ||
| { | ||
| var exception = e.ExceptionObject as Exception; | ||
| output.WriteLine($"Unhandled exception captured: {exception?.Message}"); | ||
| }; |
Copilot
AI
Apr 11, 2025
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this 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 fromManagedWebMinimalHostFixture. 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 typeThe XML documentation comment refers to
IWebHostFixtureandManagedWebHostFixture, but the actual parameter type isIWebMinimalHostFixture. 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 typeSimilar 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 typeDocumentation 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 typeDocumentation 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
📒 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 goodThe renaming from
IMinimalWebHostFixturetoIWebMinimalHostFixtureimproves 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 implementationThis new class correctly implements a self-managed version of
ManagedWebHostFixturewith 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 counterpartThis implementation follows the same pattern as
SelfManagedWebHostFixturebut 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 classThe test has been properly updated to use the new
BlockingManagedWebHostFixtureinstead of the previousBlockingWebHostFixture, 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
AsyncHostRunnerCallbackto 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
AsyncHostRunnerCallbackto 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 conventionsThe change from
GenericHostFixturetoManagedHostFixturealigns 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 clarityThe class renaming from
MinimalHostFixturetoManagedMinimalHostFixturealong 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 correctlyThe XML documentation has been properly updated to reference the new class name, maintaining code documentation quality.
2-2: Upgraded to asynchronous pattern with cancellation supportThe implementation now uses
AsyncHostRunnerCallbackwith a cancellation token instead of the synchronousHostRunnerCallback. This is an important modernization that:
- Follows .NET best practices for asynchronous operations
- Enables proper cancellation support
- Provides better resource cleanup during shutdown
The addition of the
System.Threadingnamespace supports this enhancement.Also applies to: 53-53
test/Codebelt.Extensions.Xunit.Hosting.Tests/HostTestTest.cs (1)
16-16: Updated test class to use ManagedHostFixtureThe test class has been correctly updated to extend
HostTest<ManagedHostFixture>instead ofHostTest<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 ManagedWebHostFixtureThe test class has been properly updated to use
ManagedWebHostFixtureinstead ofWebHostFixture. 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 changesThe 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 ManagedHostFixtureThis 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 supportThe change from
HostRunnerCallback(Host)toAsyncHostRunnerCallback(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 classThe test class has been properly updated to use
ManagedMinimalHostFixtureinstead ofMinimalHostFixture, 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 clarityThe class has been renamed from
MinimalWebHostFixtureExtensionstoWebMinimalHostFixtureExtensionsand references toIMinimalWebHostFixturehave been updated toIWebMinimalHostFixture, aligning with the PR objectives for improved naming clarity.Also applies to: 6-7
9-13: Documentation properly updated for interface renameThe XML documentation has been correctly updated to reference the renamed interface
IWebMinimalHostFixturethroughout.
16-17: Updated XML documentation for interface referencesThe XML comment has been updated to reference
IWebMinimalHostFixturewhile preserving references to other interfaces.
18-22: Method signature updated while preserving functionalityThe method signature has been updated to use
IWebMinimalHostFixturewhile 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 functionalityThe 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 referencesThe test class has been renamed from
GenericHostFixtureTesttoManagedHostFixtureTestwith 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 typeThe invalid host test case has been properly updated to use
ManagedHostFixtureinstead ofGenericHostFixture, 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
IMinimalWebHostFixturetoIWebMinimalHostFixturehas 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
WebHostFixtureTesttoManagedWebHostFixtureTest, including its constructor, which aligns with the renamed fixture class.
19-20: All fixture references properly updated.All instances of
WebHostFixturehave been correctly updated toManagedWebHostFixture, including test setup and theInvalidHostTest<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 ofWebHostTest<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
WebHostFixturetoManagedWebHostFixtureand now extendsManagedHostFixtureinstead 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
AsyncHostRunnerCallbackwith 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>toMinimalHostTest<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
MinimalHostFixturetoManagedMinimalHostFixtureto 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.Threadingnamespace has been added to support the use ofCancellationTokenin 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
IMinimalWebHostFixturetoIWebMinimalHostFixture- Base class reference updated to
ManagedMinimalHostFixture- Class name changed from
MinimalWebHostFixturetoManagedWebMinimalHostFixtureThese 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
MinimalWebHostFixturetoManagedWebMinimalHostFixtureto 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)toAsyncHostRunnerCallback(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>toMinimalWebHostTest<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
MinimalWebHostFixturetoManagedWebMinimalHostFixtureto 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.Threadingnamespace has been added to support the use ofCancellationTokenin the updated asynchronous host runner callback.
17-32: Improved host runner implementation with asynchronous support.The host runner callback has been enhanced:
- Changed from
Action<IHost>toFunc<IHost, CancellationToken, Task>to support asynchronous operations- Added cancellation token support for proper cancellation handling
- 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
HostRunnerCallbacktoAsyncHostRunnerCallbackto clearly indicate its asynchronous behavior. The getter and setter have been updated to work with the newFunc<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>toWebHostTest<ManagedWebHostFixture>correctly implements the renaming convention described in the PR objectives. This update is consistent with the library-wide rename ofWebHostFixturetoManagedWebHostFixture.
15-15: Field type update is consistent with the class declaration.The
_hostFixturefield has been properly updated to use theManagedWebHostFixturetype, maintaining consistency with the class declaration.
18-18: Constructor parameter type correctly updated.The constructor parameter has been appropriately updated to accept a
ManagedWebHostFixtureinstance, 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>toMinimalWebHostTest<ManagedWebMinimalHostFixture>correctly implements the renaming convention described in the PR objectives, whereMinimalWebHostFixturehas been renamed toManagedWebMinimalHostFixture.
16-16: Field type update is consistent.The
_hostFixturefield type has been properly updated to use theManagedWebMinimalHostFixturetype, maintaining consistency with the class declaration.
19-19: Constructor parameter type correctly updated.The constructor parameter has been appropriately updated to accept a
ManagedWebMinimalHostFixtureinstance, 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
hostFixtureparameter has been correctly updated to referenceManagedHostFixtureas 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
GenericHostFixturetoManagedHostFixture, 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
CreateWithHostBuilderContextmethod has been correctly updated to match the documentation in theCreatemethod, maintaining consistency across the API.
33-33: Default fixture instantiation updated in second method.The default fixture instantiation in the
CreateWithHostBuilderContextmethod has also been updated to useManagedHostFixture, 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
_hostFixturefield type has been correctly updated fromMinimalHostFixturetoManagedMinimalHostFixture, 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
ManagedMinimalHostFixtureinstance, 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 aManagedHostFixtureinstance, 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 ManagedMinimalHostFixtureThe change to use
ManagedMinimalHostFixtureinstead ofMinimalHostFixtureis consistent with the PR objectives of improving naming clarity throughout the library.
29-34: LGTM: Update to use ManagedMinimalHostFixtureThe change to use
ManagedMinimalHostFixturein theCreateWithHostBuilderContextmethod 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 IWebMinimalHostFixtureThis 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 IWebMinimalHostFixtureParameter type has been properly updated to use the renamed interface.
25-26: LGTM: Parameter type updated to IWebMinimalHostFixtureParameter type has been properly updated in the overloaded constructor.
33-34: LGTM: Parameter type updated in InitializeHostFixture methodThe 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 ManagedWebHostFixtureThe change to use
ManagedWebHostFixtureinstead ofWebHostFixtureis consistent with the PR objectives. Both the XML documentation and implementation have been properly updated.
37-42: LGTM: Update to use ManagedWebHostFixture in CreateWithHostBuilderContextDocumentation and implementation correctly updated to use the renamed class.
51-57: LGTM: Update to use ManagedWebHostFixture in RunAsyncDocumentation updated properly for the RunAsync method.
66-72: LGTM: Update to use ManagedWebHostFixture in RunWithHostBuilderContextAsyncDocumentation updated properly for the RunWithHostBuilderContextAsync method.
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/MinimalWebHostTestFactory.cs (4)
26-29: LGTM: Parameter type and implementation updatedThe parameter type has been properly updated to use
IWebMinimalHostFixtureand the implementation usesManagedWebMinimalHostFixture, which aligns with the PR objectives.
39-42: LGTM: Parameter type and implementation updatedProperly updated parameter type and implementation in the CreateWithHostBuilderContext method.
53-57: LGTM: Parameter type updated in RunAsyncParameter type has been properly updated to use the renamed interface.
68-72: LGTM: Parameter type updated in RunWithHostBuilderContextAsyncParameter type has been properly updated to use the renamed interface.
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
|



This pull request includes significant changes to the
Codebelt.Extensions.Xunit.Hosting.AspNetCorelibrary, 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:
IMinimalWebHostFixturetoIWebMinimalHostFixtureto better reflect its purpose.WebHostFixturetoManagedWebHostFixtureto indicate it now extendsManagedHostFixture.MinimalWebHostFixturetoManagedWebMinimalHostFixtureto align with the new naming convention.New Fixture Classes:
BlockingManagedWebHostFixtureclass to provide a synchronous, blocking implementation ofManagedWebHostFixture.SelfManagedWebHostFixtureclass, which represents a self-managed implementation ofManagedWebHostFixture.Method and Property Updates:
MinimalWebHostTestclass to useIWebMinimalHostFixtureinstead ofIMinimalWebHostFixture. [1] [2]ManagedWebHostFixtureandManagedWebMinimalHostFixtureto useAsyncHostRunnerCallbackinstead ofHostRunnerCallbackfor asynchronous operations. [1] [2]Factory Method Adjustments:
MinimalWebHostTestFactorymethods to useManagedWebHostFixtureandIWebMinimalHostFixtureinstead 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.AspNetCorelibrary.Summary by CodeRabbit