Skip to content

Full test coverage for OperatorDomainService — fix dead code branches and missing edge cases#1506

Merged
StuartFerguson merged 6 commits intomasterfrom
copilot/update-test-coverage-operator-service
Feb 20, 2026
Merged

Full test coverage for OperatorDomainService — fix dead code branches and missing edge cases#1506
StuartFerguson merged 6 commits intomasterfrom
copilot/update-test-coverage-operator-service

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 20, 2026

OperatorDomainService had several uncovered branches: the stateResult.IsFailed path in UpdateOperator was permanently dead code, the Guid.Empty operatorId path in CreateOperator was untested, and both methods had copy-paste bugs where estateResult.IsFailed was checked twice instead of checking operatorResult.IsFailed.

Bug fixes

  • CreateOperator / UpdateOperator: both methods re-checked estateResult.IsFailed after fetching the operator aggregate instead of operatorResult.IsFailed, silently swallowing operator fetch failures.

Dead code elimination — UpdateOperator stateResult.IsFailed

OperatorAggregate.UpdateOperator always returned Result.Success(), making the service's stateResult.IsFailed guard unreachable. Fixed by adding an IsCreated validation to the aggregate method (where domain validation belongs) and removing the duplicate service-level guard:

// OperatorAggregate.UpdateOperator — domain validation now lives here
if (aggregate.IsCreated == false)
    return Result.Invalid("Operator has not been created");

The service-level if (operatorAggregate.IsCreated == false) guard introduced in an earlier pass is removed; stateResult.IsFailed is now the single coverage path for this case.

New / fixed tests

Test Covers
CreateOperator_OperatorIdIsEmpty_OperatorIsCreated Guid.Empty → Guid.NewGuid() switch in CreateOperator
CreateOperator_OperatorNameEmpty_ResultFailed stateResult.IsFailed in CreateOperator (aggregate rejects empty name)
CreateOperator_GetEstateFailed / GetOperatorFailed / SaveFailed / ExceptionThrown All failure exits in CreateOperator
UpdateOperator_OperatorNotCreated_ResultFailed stateResult.IsFailed in UpdateOperator (now via aggregate validation) — previously passed accidentally due to missing mock
UpdateOperator_GetEstateFailed / EstateNotCreated / GetOperatorFailed / SaveFailed / ExceptionThrown All failure exits in UpdateOperator
Original prompt

This section details on the original issue you should resolve

<issue_title>Update Test Coverage on Operator Domain service</issue_title>
<issue_description>Each domain service method needs new tests added to cover all cases, failure and exception cases need to be covered.</issue_description>

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


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…rage for OperatorDomainService

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] Update test coverage for operator domain service Fix operator result failure checks and add full failure/exception test coverage for OperatorDomainService Feb 20, 2026
Copilot AI requested a review from StuartFerguson February 20, 2026 16:53
…ateOperator operator-not-created guard

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title Fix operator result failure checks and add full failure/exception test coverage for OperatorDomainService Full test coverage for OperatorDomainService — fix uncovered branches and a missing guard Feb 20, 2026
…d add CreateOperator Guid.Empty test

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title Full test coverage for OperatorDomainService — fix uncovered branches and a missing guard Full test coverage for OperatorDomainService — fix dead code branches and missing edge cases Feb 20, 2026
@StuartFerguson StuartFerguson marked this pull request as ready for review February 20, 2026 17:29
@StuartFerguson StuartFerguson merged commit f5e3bbc into master Feb 20, 2026
10 checks passed
@github-actions github-actions Bot deleted the copilot/update-test-coverage-operator-service branch April 22, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Test Coverage on Operator Domain service

2 participants