using Heimdall.Application.Common; using Heimdall.Application.Settings.Commands.DeleteAppSetting; using Heimdall.Application.Tests.Common; using Heimdall.Domain.Entities; using NSubstitute; namespace Heimdall.Application.Tests.Handlers.Settings; public class DeleteAppSettingHandlerTests { [Fact] public async Task Delete_setting_should_return_success() { var setting = new AppSetting("test.key", "value"); var context = Substitute.For(); context.AppSettings.Returns(MockDbSetHelper.CreateFor([setting])); context.SaveChangesWithRetryAsync(Arg.Any(), Arg.Any()).Returns(Task.CompletedTask); var handler = new DeleteAppSettingCommandHandler(context); var result = await handler.Handle(new DeleteAppSettingCommand("test.key"), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task Delete_nonexistent_setting_should_return_not_found() { var context = Substitute.For(); context.AppSettings.Returns(MockDbSetHelper.CreateFor()); var handler = new DeleteAppSettingCommandHandler(context); var result = await handler.Handle(new DeleteAppSettingCommand("missing.key"), CancellationToken.None); result.IsSuccess.ShouldBeFalse(); result.StatusCode.ShouldBe(404); } }