using Heimdall.Application.Common; using Heimdall.Application.Vehicles.Commands.DeleteVehicle; using Heimdall.Application.Tests.Common; using Heimdall.Domain.Entities; using NSubstitute; namespace Heimdall.Application.Tests.Handlers.Vehicles; public class DeleteVehicleHandlerTests { [Fact] public async Task Delete_vehicle_should_return_success() { var vehicle = new Vehicle("PLATE-1"); var context = Substitute.For(); context.Vehicles.Returns(MockDbSetHelper.CreateFor(new[] { vehicle })); var handler = new DeleteVehicleCommandHandler(context); var result = await handler.Handle(new DeleteVehicleCommand(vehicle.Id), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); await context.Received(1).SaveChangesWithRetryAsync(Arg.Any(), Arg.Any()); } [Fact] public async Task Delete_vehicle_not_found_should_return_not_found() { var context = Substitute.For(); context.Vehicles.Returns(MockDbSetHelper.CreateFor()); var handler = new DeleteVehicleCommandHandler(context); var result = await handler.Handle(new DeleteVehicleCommand(Guid.NewGuid()), CancellationToken.None); result.IsSuccess.ShouldBeFalse(); result.StatusCode.ShouldBe(404); } }