1
0
Fork 0

refactor(P5b-2): 출력 형식 교집합 로직을 ProviderRegistry로 추출 (매트릭스 필터 테스트화)

MainWindow.RefreshAvailableOutputFormats에 박혀 있던 '큐 전체 공통 출력' 교집합 계산을
ProviderRegistry.AvailableOutputsForFiles 순수 쿼리로 추출 — 코드비하인드 18줄 → 2줄, 헤드리스 테스트 가능.

- ProviderRegistry.AvailableOutputsForFiles(sourcePaths): 비면 전체 출력, 아니면 OutputsForFile 교집합.
- MainWindow: 인라인 교집합 루프 제거 → 레지스트리 메서드 호출. UI(콤보 빌드)는 그대로.
- 테스트 2개: 빈 입력=전체, png+csv 혼합 시 jpg가 교집합에서 빠짐(매트릭스 필터 핵심 동작).

81 → 83개 테스트 전부 그린, 빌드 0경고/0오류.
This commit is contained in:
Yun Chan 2026-06-02 09:53:26 +09:00
parent ba5738e705
commit e95ec967e6
3 changed files with 43 additions and 19 deletions

View file

@ -79,6 +79,25 @@ public sealed class ProviderRegistry
public IReadOnlyList<string> OutputsForFile(string sourcePath)
=> OutputsForInput(Path.GetExtension(sourcePath));
/// <summary>
/// 여러 입력 파일이 '공통으로' 변환 가능한 출력 확장자(교집합). UI 매트릭스 자동 필터링의 핵심 —
/// 큐의 모든 파일을 같은 형식으로 변환할 수 있는 출력만 노출한다. 비어 있으면 전체 출력 확장자.
/// (MainWindow.RefreshAvailableOutputFormats에서 추출 — 순수 쿼리라 헤드리스 테스트 가능.)
/// </summary>
public IReadOnlyCollection<string> AvailableOutputsForFiles(IReadOnlyCollection<string> sourcePaths)
{
if (sourcePaths.Count == 0) return AllOutputExtensions;
HashSet<string>? intersection = null;
foreach (var path in sourcePaths)
{
var outs = new HashSet<string>(OutputsForFile(path), StringComparer.OrdinalIgnoreCase);
if (intersection is null) intersection = outs;
else intersection.IntersectWith(outs);
}
return intersection ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase);
}
public IReadOnlyCollection<string> AllInputExtensions => _allInputs;
public IReadOnlyCollection<string> AllOutputExtensions => _allOutputs;