public void Include_terms_filter_works(ReleaseProfileDataFilterer sut) { var filter = new[] { "1", "2" }; var terms = new TermData[] { new() { TrashId = "1", Term = "term1" }, new() { TrashId = "2", Term = "term2" }, new() { TrashId = "3", Term = "term3" } }; var result = sut.IncludeTerms(terms, filter); result.Should().BeEquivalentTo(new TermData[] { new() { TrashId = "1", Term = "term1" }, new() { TrashId = "2", Term = "term2" } });
public async Task Process(bool isPreview, SonarrConfiguration config) { var profilesFromGuide = _guide.GetReleaseProfileData(); var filteredProfiles = new List <(ReleaseProfileData Profile, IReadOnlyCollection <string> Tags)>(); var filterer = new ReleaseProfileDataFilterer(_log); var configProfiles = config.ReleaseProfiles.SelectMany(x => x.TrashIds.Select(y => (TrashId: y, Config: x))); foreach (var(trashId, configProfile) in configProfiles) { // For each release profile specified in our YAML config, find the matching profile in the guide. var selectedProfile = profilesFromGuide.FirstOrDefault(x => x.TrashId.EqualsIgnoreCase(trashId)); if (selectedProfile is null) { _log.Warning("A release profile with Trash ID {TrashId} does not exist", trashId); continue; } _log.Debug("Found Release Profile: {ProfileName} ({TrashId})", selectedProfile.Name, selectedProfile.TrashId); if (configProfile.Filter != null) { _log.Debug("This profile will be filtered"); var newProfile = filterer.FilterProfile(selectedProfile, configProfile.Filter); if (newProfile is not null) { selectedProfile = newProfile; } } if (isPreview) { Utils.PrintTermsAndScores(selectedProfile); continue; } filteredProfiles.Add((selectedProfile, configProfile.Tags)); } await ProcessReleaseProfiles(filteredProfiles); }