Skip to content

Add unit tests for OperatorRequestHandler#791

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

Add unit tests for OperatorRequestHandler#791
StuartFerguson merged 4 commits intomainfrom
copilot/add-operator-request-handler-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

OperatorRequestHandler had no test coverage. This adds 10 unit tests covering all 5 MediatR handler methods with both success and failure paths.

Tests added

  • GetOperatorsQuery – returns operator list on success; propagates failure
  • GetOperatorQuery – returns single operator model on success; propagates failure
  • CreateOperatorCommand – returns success result; propagates failure
  • UpdateOperatorCommand – returns success result; propagates failure
  • GetOperatorsForDropDownQuery – returns drop-down model list on success; propagates failure

Each test mocks IApiClient, asserts the result state via Shouldly, and verifies the correct client method is called exactly once.

[Fact]
public async Task Handle_GetOperatorsQuery_ReturnsSuccess_WhenApiClientSucceeds()
{
    var query = new OperatorQueries.GetOperatorsQuery(CorrelationIdHelper.New(), Guid.NewGuid());
    _mockApiClient
        .Setup(c => c.GetOperators(query, It.IsAny<CancellationToken>()))
        .ReturnsAsync(Result.Success(operators));

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

    result.IsSuccess.ShouldBeTrue();
    _mockApiClient.Verify(c => c.GetOperators(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 FullyQualifiedName~OperatorRequestHandlerTests (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>OperatorRequestHandler 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)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add unit tests for OperatorRequestHandler with high coverage Add unit tests for OperatorRequestHandler Feb 23, 2026
Copilot AI requested a review from StuartFerguson February 23, 2026 21:20
@StuartFerguson StuartFerguson marked this pull request as ready for review February 24, 2026 05:51
@StuartFerguson StuartFerguson merged commit dda1ddd into main Feb 24, 2026
10 checks passed
@github-actions github-actions Bot deleted the copilot/add-operator-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.

OperatorRequestHandler Unit Tests

2 participants