Add failure and exception case test coverage for EstateDomainService#1503
Merged
StuartFerguson merged 3 commits intomasterfrom Feb 20, 2026
Merged
Conversation
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update test coverage for estate domain service methods
Add failure case test coverage for EstateDomainService
Feb 20, 2026
Member
|
@copilot what about the exception cases ? |
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Contributor
Author
Added four exception-case tests in commit |
Copilot
AI
changed the title
Add failure case test coverage for EstateDomainService
Add failure and exception case test coverage for EstateDomainService
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EstateDomainServiceTestsonly covered happy paths. Each method inEstateDomainServicehas multiple early-return failure branches (aggregate fetch failure, domain state validation failure, save failure) and a top-level exception handler that were entirely untested.New failure case tests
CreateEstateGetAggregateOrFailurereturns failureestateAggregate.Create()fails (empty estate name)AggregateService.Save()failsAddOperatorToEstateGet<OperatorAggregate>returns failureGetLatest<EstateAggregate>returns failureestateAggregate.AddOperator()fails (estate not yet created)AggregateService.Save()failsCreateEstateUserGetLatest<EstateAggregate>returns failureestateAggregate.AddSecurityUser()fails (estate not yet created)AggregateService.Save()failsRemoveOperatorFromEstateGetLatest<EstateAggregate>returns failureestateAggregate.RemoveOperator()fails (estate not created / operator not added)AggregateService.Save()failsEach test follows the established pattern — mock the relevant dependency to return
Result.Failure()or use anEmptyEstateAggregateto trigger domain validation failure, then assertresult.IsFailed.New exception case tests
Each method also has a
catch (Exception ex)block that returnsResult.Failure(ex.GetExceptionMessages()). One test per method covers this path by configuring the first dependency call to throw anException:EstateDomainService_CreateEstate_ExceptionThrown_ResultIsFailedEstateDomainService_AddOperatorToEstate_ExceptionThrown_ResultIsFailedEstateDomainService_CreateEstateUser_ExceptionThrown_ResultIsFailedEstateDomainService_RemoveOperatorFromEstate_ExceptionThrown_ResultIsFailedOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.