Skip to content

Add unit tests for TransactionRequestHandler and SettlementRequestHandler#792

Merged
StuartFerguson merged 3 commits intomainfrom
copilot/add-transaction-request-handler-tests
Feb 24, 2026
Merged

Add unit tests for TransactionRequestHandler and SettlementRequestHandler#792
StuartFerguson merged 3 commits intomainfrom
copilot/add-transaction-request-handler-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

TransactionRequestHandler and SettlementRequestHandler had no unit test coverage. This adds tests targeting near-100% coverage for both handlers.

Changes

  • New file: EstateManagementUI.BlazorServer.Tests/RequestHandlers/TransactionRequestHandlerTests.cs
    • 16 tests (success + failure path for each of the 8 handler methods)
    • Follows the same Mock<IApiClient> + Shouldly pattern as DateRequestHandlerTests.cs

Handlers covered

Handler Query
TransactionRequestHandler GetTodaysSalesQuery
GetTodaysFailedSalesQuery
GetTransactionDetailQuery
GetMerchantTransactionSummaryQuery
GetOperatorTransactionSummaryQuery
GetProductPerformanceQuery
GetTodaysSalesByHourQuery
SettlementRequestHandler GetTodaysSettlementQuery

Each test verifies the handler delegates to IApiClient and correctly propagates both Result.Success and Result.Failure responses:

[Fact]
public async Task Handle_GetTodaysSalesQuery_ReturnsSuccess_WhenApiClientSucceeds()
{
    var query = new TransactionQueries.GetTodaysSalesQuery(CorrelationIdHelper.New(), estateId, comparisonDate);
    _mockApiClient.Setup(c => c.GetTodaysSales(query, It.IsAny<CancellationToken>()))
                  .ReturnsAsync(Result.Success(model));

    var result = await _handler.Handle(query, CancellationToken.None);

    result.IsSuccess.ShouldBeTrue();
    _mockApiClient.Verify(c => c.GetTodaysSales(query, It.IsAny<CancellationToken>()), Times.Once);
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • f.feedz.io
    • Triggering command: /usr/bin/dotnet dotnet test EstateManagementUI.BlazorServer.Tests/EstateManagementUI.BlazorServer.Tests.csproj --filter TransactionRequestHandlerTests (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore EstateManagementUI.BlazorServer.Tests/EstateManagementUI.BlazorServer.Tests.csproj --configfile EstateManagementUI.BlazorServer/NuGet.Config (dns block)
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp -u bin/WALinuxAgent-2.15.0.1-py3.12.egg -collect-logs (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>TransactionRequestHandler Unit Tests</issue_title>
<issue_description>Ensure a good level of code coverage as close to 100% as possible</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for TransactionRequestHandler Add unit tests for TransactionRequestHandler and SettlementRequestHandler Feb 23, 2026
Copilot AI requested a review from StuartFerguson February 23, 2026 21:22
@StuartFerguson StuartFerguson marked this pull request as ready for review February 24, 2026 09:40
@StuartFerguson StuartFerguson merged commit e061401 into main Feb 24, 2026
10 checks passed
@github-actions github-actions Bot deleted the copilot/add-transaction-request-handler-tests branch April 26, 2026 01: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.

TransactionRequestHandler Unit Tests

2 participants