using FluentAssertions; using FluentValidation; using NUnit.Framework; using Recyclarr.TestLibrary; using TrashLib.Config.Services; namespace TrashLib.Tests.Config.Services; [TestFixture] [Parallelizable(ParallelScope.All)] public class ServiceConfigurationTest : IntegrationFixture { [Test] public void Validation_fails_for_all_missing_required_properties() { // default construct which should yield default values (invalid) for all required properties var config = new ServiceConfiguration(); var validator = ServiceLocator.Resolve>(); var result = validator.Validate(config); var messages = new ServiceValidationMessages(); var expectedErrorMessageSubstrings = new[] { messages.ApiKey, messages.BaseUrl }; result.IsValid.Should().BeFalse(); result.Errors.Select(e => e.ErrorMessage) .Should().BeEquivalentTo(expectedErrorMessageSubstrings); } [Test] public void Fail_when_trash_ids_missing() { var config = new ServiceConfiguration { BaseUrl = "valid", ApiKey = "valid", CustomFormats = new List { new() // Empty to force validation failure } }; var validator = ServiceLocator.Resolve>(); var result = validator.Validate(config); var messages = new ServiceValidationMessages(); var expectedErrorMessageSubstrings = new[] { messages.CustomFormatTrashIds }; result.IsValid.Should().BeFalse(); result.Errors.Select(e => e.ErrorMessage) .Should().BeEquivalentTo(expectedErrorMessageSubstrings); } }