Skip to content

Add unit tests for EstateRequestHandler to achieve full coverage#789

Merged
StuartFerguson merged 4 commits into
mainfrom
copilot/add-estate-request-handler-tests
Feb 24, 2026
Merged

Add unit tests for EstateRequestHandler to achieve full coverage#789
StuartFerguson merged 4 commits into
mainfrom
copilot/add-estate-request-handler-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

EstateRequestHandler had no unit test coverage across its four MediatR handler methods.

Changes

  • New file: EstateManagementUI.BlazorServer.Tests/RequestHandlers/EstateRequestHandlerTests.cs
    • 8 tests covering all 4 handler methods × (success + failure) paths:
      • GetEstateQueryApiClient.GetEstate
      • AddOperatorToEstateCommandApiClient.AddEstateOperator
      • RemoveOperatorFromEstateCommandApiClient.RemoveEstateOperator
      • GetAssignedOperatorsQueryApiClient.GetEstateAssignedOperators
    • Each test verifies IsSuccess/IsFailed on the returned Result and asserts the API client was called exactly once via Moq.Verify
[Fact]
public async Task Handle_GetEstateQuery_ReturnsSuccess_WhenApiClientSucceeds()
{
    var query = new EstateQueries.GetEstateQuery(CorrelationIdHelper.New(), estateId);
    _mockApiClient.Setup(c => c.GetEstate(query, It.IsAny<CancellationToken>()))
                  .ReturnsAsync(Result.Success(estateModel));

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

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

Follows the same conventions as the existing DateRequestHandlerTests.

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 FullyQualifiedName~EstateRequestHandlerTests (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 (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/EstateManagementUI/EstateManagementUI/EstateManagementUI.sln --packages /home/REDACTED/work/EstateManagementUI/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/EstateManagementUI/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/EstateManagementUI/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (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>EstateRequestHandler 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.

…r all 4 handler methods

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for EstateRequestHandler Add unit tests for EstateRequestHandler to achieve full coverage Feb 23, 2026
Copilot AI requested a review from StuartFerguson February 23, 2026 21:09
@StuartFerguson StuartFerguson marked this pull request as ready for review February 23, 2026 21:11
@StuartFerguson StuartFerguson merged commit 5cfd3dd into main Feb 24, 2026
10 checks passed
@github-actions github-actions Bot deleted the copilot/add-estate-request-handler-tests branch April 25, 2026 01:14
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.

EstateRequestHandler Unit Tests

2 participants