Skip to content

Conversation

@gimlichael
Copy link
Member

@gimlichael gimlichael commented Sep 10, 2025

Summary

  • test dependency injection bindings for Azure Queue Storage command queue and event bus, with and without markers

Testing

  • dotnet test test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj --collect:"XPlat Code Coverage" --results-directory coverage --no-build --verbosity minimal

https://chatgpt.com/codex/tasks/task_e_68c1c7ccf40c8330a1d8efbfe141bce2

Summary by CodeRabbit

  • Tests

    • Added a comprehensive test suite for QueueStorage dependency injection covering command queues and event buses, including marker-based scenarios.
    • Verifies service registrations, options configuration delegates, and serializer selection across Newtonsoft.Json and System.Text.Json paths.
    • Improves reliability and guards against regressions in Azure QueueStorage integrations.
  • Chores

    • Introduced a dedicated test project and minimal marker types to support the new tests.

@coderabbitai
Copy link

coderabbitai bot commented Sep 10, 2025

Walkthrough

Adds a new test project with DI integration tests for Azure Queue Storage components. Introduces two empty marker structs for generic registrations. Tests verify service registrations, generic marker variants, and options delegates for AzureCommandQueue and AzureEventBus using both Newtonsoft.Json and System.Text.Json marshallers.

Changes

Cohort / File(s) Summary
Test markers
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs, test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/QueueMarker.cs
Add empty public structs BusMarker and QueueMarker in Assets namespace for generic DI registrations.
ServiceCollection DI tests
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs
Add tests asserting DI registrations and resolutions for AzureCommandQueue and AzureEventBus (non-generic and marker-generic), plus options delegate equivalence checks and marshaller usage.
Test project setup
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
Add test project file, root namespace, project references to core libraries, and include Assets folder.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Test
  participant DI as ServiceCollection
  participant Prov as ServiceProvider
  participant CQ as AzureCommandQueue / AzureCommandQueue<TMarker>
  participant EB as AzureEventBus / AzureEventBus<TMarker>

  Note over Dev,DI: Register command queue
  Dev->>DI: AddAzureCommandQueue(azureSetup)
  DI-->>DI: Register IPointToPointChannel/I(S/R) for ICommand -> CQ
  DI-->>DI: Store AzureQueueOptions delegate

  Note over Dev,DI: Register event bus
  Dev->>DI: AddAzureEventBus(eventBusSetup)
  DI-->>DI: Register IPubSub/I(Pub/Sub) for IIntegrationEvent -> EB
  DI-->>DI: Store EventBusOptions delegate

  Dev->>DI: BuildServiceProvider()
  DI-->>Dev: Prov

  Dev->>Prov: GetService(IPointToPointChannel<ICommand>[, TMarker])
  Prov-->>Dev: CQ instance

  Dev->>Prov: GetService(IPublishSubscribeChannel<IIntegrationEvent>[, TMarker])
  Prov-->>Dev: EB instance

  Note over Dev: Assert types and option delegate equivalence
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (2 passed, 1 warning)

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add Queue Storage DI tests" is concise and accurately reflects the primary change in the PR (adding dependency-injection tests for queue storage), matching the PR objectives and the added test files. It is specific enough for a reviewer to understand the main intent while remaining brief.

Poem

I twitch my nose at queues and bus,
New markers hop—no extra fuss.
The tests all nibble DI’s greens,
Ensuring options match the means.
With JSON crunch and tidy routes,
I thump approval: all checks out. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/improve-test-coverage-for-repository

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.

@codecov
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.92%. Comparing base (52b1264) to head (287b4bf).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #40      +/-   ##
==========================================
+ Coverage   77.82%   78.92%   +1.10%     
==========================================
  Files         177      177              
  Lines        3711     3711              
  Branches      365      365              
==========================================
+ Hits         2888     2929      +41     
+ Misses        821      780      -41     
  Partials        2        2              

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link

@gimlichael gimlichael self-assigned this Sep 11, 2025
@gimlichael gimlichael marked this pull request as ready for review September 11, 2025 00:04
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 (4)
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/QueueMarker.cs (1)

3-5: Make the marker immutable and add XML docs.

Prevents accidental mutation and aligns with repo doc-comment guidelines.

 namespace Savvyio.Extensions.DependencyInjection.QueueStorage.Assets
 {
-    public struct QueueMarker
-    {
-    }
+    /// <summary>
+    /// Marker type used to differentiate generic DI registrations in tests.
+    /// </summary>
+    public readonly struct QueueMarker
+    {
+    }
 }
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj (1)

11-12: Remove redundant folder include.

MSBuild includes folders implicitly; this entry is unnecessary noise.

-  <ItemGroup>
-    <Folder Include="Assets\" />
-  </ItemGroup>
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs (1)

3-5: Mirror QueueMarker: make readonly and document.

Consistent, immutable marker with XML docs.

 namespace Savvyio.Extensions.DependencyInjection.QueueStorage.Assets
 {
-    public struct BusMarker
-    {
-    }
+    /// <summary>
+    /// Marker type used to differentiate generic DI registrations for event bus in tests.
+    /// </summary>
+    public readonly struct BusMarker
+    {
+    }
 }
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs (1)

43-43: Enable DI validation and assert marshaller type.

Catches misconfigured registrations early and verifies the intended marshaller is wired.

-            var provider = services.BuildServiceProvider();
+            using var provider = services.BuildServiceProvider(new ServiceProviderOptions
+            {
+                ValidateOnBuild = true,
+                ValidateScopes = true
+            });
+            Assert.IsType<NewtonsoftJsonMarshaller>(provider.GetRequiredService<IMarshaller>());

-            var provider = services.BuildServiceProvider();
+            using var provider = services.BuildServiceProvider(new ServiceProviderOptions
+            {
+                ValidateOnBuild = true,
+                ValidateScopes = true
+            });
+            Assert.IsType<JsonMarshaller>(provider.GetRequiredService<IMarshaller>());

-            var provider = services.BuildServiceProvider();
+            using var provider = services.BuildServiceProvider(new ServiceProviderOptions
+            {
+                ValidateOnBuild = true,
+                ValidateScopes = true
+            });
+            Assert.IsType<NewtonsoftJsonMarshaller>(provider.GetRequiredService<IMarshaller>());

-            var provider = services.BuildServiceProvider();
+            using var provider = services.BuildServiceProvider(new ServiceProviderOptions
+            {
+                ValidateOnBuild = true,
+                ValidateScopes = true
+            });
+            Assert.IsType<JsonMarshaller>(provider.GetRequiredService<IMarshaller>());

Also applies to: 76-76, 114-114, 161-161

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52b1264 and 287b4bf.

📒 Files selected for processing (4)
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs (1 hunks)
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/QueueMarker.cs (1 hunks)
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj (1 hunks)
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
test/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Place tests in dedicated test projects/folders (under the test directory)

Files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/QueueMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs
test/**/*.Tests/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Unit tests for an assembly should reside in a corresponding .Tests assembly (e.g., Savvyio.Foo.Tests)

Files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/QueueMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs
test/**/*.csproj

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Override RootNamespace in test project .csproj to match the product assembly namespace (e.g., Savvyio.Foo)

Files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
test/**/*.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use namespaces in tests that mirror the source code structure

Files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/QueueMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs
**/*.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.cs: Follow the repository’s established XML documentation style
Add XML documentation comments to public and protected classes and methods where appropriate

Files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/QueueMarker.cs
  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs
**/*Test.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*Test.cs: All unit test classes must inherit from Codebelt.Extensions.Xunit.Test
Use [Fact] for standard unit tests
Use [Theory] with [InlineData] or other data sources for parameterized tests
Test method names should be descriptive and express expected behavior (e.g., ShouldReturnTrue_WhenConditionIsMet)
Use xUnit Assert methods for all assertions (e.g., Assert.Equal, Assert.NotNull, Assert.Contains)
Keep tests focused, isolated, deterministic, and repeatable; avoid external systems except xUnit and Codebelt.Extensions.Xunit
Prefer dummies, fakes, stubs, and spies; use Moq-based mocks only when necessary
Before overriding or mocking, ensure targeted methods are virtual or abstract
Never mock IMarshaller; use a new JsonMarshaller instance instead

Files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs
test/**/*Test.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Test class files must be named with a Test suffix (e.g., CommandDispatcherTest)

Files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs
🧠 Learnings (4)
📚 Learning: 2025-08-31T21:08:55.124Z
Learnt from: gimlichael
PR: codebeltnet/savvyio#39
File: test/Savvyio.Extensions.QueueStorage.Tests/Savvyio.Extensions.QueueStorage.Tests.csproj:7-9
Timestamp: 2025-08-31T21:08:55.124Z
Learning: In the Savvyio codebase, Directory.Build.props automatically configures test projects (identified by path patterns containing "test/" or ".Tests") with IsPackable=false and PrivateAssets=all for PackageReferences, eliminating the need to manually add these settings to individual test project files.

Applied to files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
📚 Learning: 2025-08-31T21:29:11.431Z
Learnt from: CR
PR: codebeltnet/savvyio#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-31T21:29:11.431Z
Learning: Applies to test/**/*.csproj : Override RootNamespace in test project .csproj to match the product assembly namespace (e.g., <RootNamespace>Savvyio.Foo</RootNamespace>)

Applied to files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
📚 Learning: 2025-08-31T21:08:55.124Z
Learnt from: gimlichael
PR: codebeltnet/savvyio#39
File: test/Savvyio.Extensions.QueueStorage.Tests/Savvyio.Extensions.QueueStorage.Tests.csproj:7-9
Timestamp: 2025-08-31T21:08:55.124Z
Learning: In the Savvyio codebase, Directory.Build.props automatically handles test project configuration through the IsTestProject property (determined by project names ending with 'Tests'). For test projects, it automatically sets IsPackable=false and includes common test packages with PrivateAssets=all, making manual configuration in individual test project files unnecessary.

Applied to files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
📚 Learning: 2025-08-31T21:29:11.431Z
Learnt from: CR
PR: codebeltnet/savvyio#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-31T21:29:11.431Z
Learning: Applies to test/**/*.Tests/** : Unit tests for an assembly should reside in a corresponding .Tests assembly (e.g., Savvyio.Foo.Tests)

Applied to files:

  • test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests.csproj
🧬 Code graph analysis (2)
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/Assets/BusMarker.cs (3)
test/Savvyio.Extensions.DependencyInjection.SimpleQueueService.Tests/Assets/BusMarker.cs (1)
  • Savvyio (1-7)
test/Savvyio.Extensions.DependencyInjection.RabbitMQ.Tests/Assets/BusMarker.cs (2)
  • Savvyio (1-7)
  • BusMarker (3-6)
test/Savvyio.Extensions.DependencyInjection.NATS.Tests/Assets/BusMarker.cs (2)
  • Savvyio (1-7)
  • BusMarker (3-6)
test/Savvyio.Extensions.DependencyInjection.QueueStorage.Tests/ServiceCollectionExtensionsTest.cs (1)
test/Savvyio.Extensions.DependencyInjection.SimpleQueueService.Tests/ServiceCollectionExtensionsTest.cs (2)
  • ServiceCollectionExtensionsTest (23-160)
  • Savvyio (21-161)

@gimlichael
Copy link
Member Author

Remember to update solution.

@gimlichael gimlichael merged commit de29c49 into main Sep 14, 2025
146 checks passed
@gimlichael gimlichael deleted the codex/improve-test-coverage-for-repository branch September 14, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants