using Heimdall.Application.Common; using Heimdall.Application.Persons.Commands.DeletePerson; using Heimdall.Application.Tests.Common; using Heimdall.Domain.Entities; using NSubstitute; namespace Heimdall.Application.Tests.Handlers.Persons; public class DeletePersonHandlerTests { [Fact] public async Task Delete_person_should_return_success() { var person = new Person("Test Person"); var context = Substitute.For(); context.Persons.Returns(MockDbSetHelper.CreateFor([person])); var handler = new DeletePersonCommandHandler(context); var result = await handler.Handle(new DeletePersonCommand(person.Id), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); await context.Received(1).SaveChangesWithRetryAsync(Arg.Any(), Arg.Any()); } [Fact] public async Task Delete_nonexistent_person_should_return_not_found() { var context = Substitute.For(); context.Persons.Returns(MockDbSetHelper.CreateFor()); var handler = new DeletePersonCommandHandler(context); var result = await handler.Handle(new DeletePersonCommand(Guid.NewGuid()), CancellationToken.None); result.IsSuccess.ShouldBeFalse(); result.StatusCode.ShouldBe(404); } }