Add unit tests, dedupe FFmpeg output filtering, harden settings records
Implements the suggestions from the last review pass:
- Add AmiReel.Tests (MSTest), covering the pure logic in Models/ and
Services/: SupportedVideoFormats, AppSettings normalization,
UserFacingErrors.Summarize, the new FfmpegProgressParser/
FfmpegOutputFilter, RenderPipeline.Validate, BuildProgressMessage, and
MoveSourceVideos. 59 tests, all passing. UI code-behind and anything that
spawns an actual FFmpeg process are left to manual/integration testing.
Exclude AmiReel.Tests\**\*.cs from AmiReel.csproj's default item glob —
it's a subfolder of the app project now, so without the exclude the app
itself was compiling the MSTest-only test files.
- Extract the FFmpeg version/library-banner boilerplate list that
ProcessRunner (live log filter) and UserFacingErrors (error summarizer)
had each duplicated into a shared FfmpegOutputFilter.IsBoilerplateLine;
each caller keeps its own remaining context-specific checks on top.
Also extract ProcessRunner's line-parsing regexes into a standalone
FfmpegProgressParser so it's directly unit-testable without spawning a
process.
- Convert AppSettings and RenderSettings from positional record
constructors to named `required` init properties. Both records had
runs of same-typed consecutive parameters (three string timing fields
in AppSettings; three doubles then five ints in RenderSettings) that a
positional constructor would let get silently transposed at a call site
without the compiler catching it. Update the two call sites
(MainPage.xaml.cs) to object-initializer syntax.
- Add Properties/AssemblyInfo.cs with InternalsVisibleTo("AmiReel.Tests")
and make Validate/BuildProgressMessage/IsNoise internal so tests can
reach them directly instead of only through process-spawning entry
points.
- README: document `dotnet test`, and note that Package.appxmanifest's
Identity is a local-dev placeholder that needs a real publisher/cert
before MSIX distribution.
Verified: dotnet build (solution + test project) is 0 warnings/errors,
dotnet test is 59/59 passing, and the app still launches unchanged.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+30
-26
@@ -222,19 +222,21 @@ public sealed partial class MainPage : Page
|
||||
throw new ArgumentException("Thumbnail interval must be at least one second.");
|
||||
|
||||
EncoderMode encoder = Enum.Parse<EncoderMode>(SelectedEncoder());
|
||||
return new(
|
||||
_inputs.ToList(),
|
||||
EndCardBox.Text.Trim(),
|
||||
OutputFolderBox.Text.Trim(),
|
||||
OutputNameBox.Text.Trim(),
|
||||
FfmpegPathBox.Text.Trim(),
|
||||
FfprobePathBox.Text.Trim(),
|
||||
encoder,
|
||||
Number(TrimBox.Text, "trim start"),
|
||||
Number(FadeBox.Text, "fade"),
|
||||
Number(HoldBox.Text, "end-card hold"),
|
||||
interval,
|
||||
MoveSourcesBox.IsChecked == true);
|
||||
return new RenderSettings
|
||||
{
|
||||
InputFiles = _inputs.ToList(),
|
||||
EndCardPath = EndCardBox.Text.Trim(),
|
||||
OutputDirectory = OutputFolderBox.Text.Trim(),
|
||||
OutputName = OutputNameBox.Text.Trim(),
|
||||
FfmpegPath = FfmpegPathBox.Text.Trim(),
|
||||
FfprobePath = FfprobePathBox.Text.Trim(),
|
||||
Encoder = encoder,
|
||||
TrimStart = Number(TrimBox.Text, "trim start"),
|
||||
FadeSeconds = Number(FadeBox.Text, "fade"),
|
||||
EndCardHoldSeconds = Number(HoldBox.Text, "end-card hold"),
|
||||
ThumbnailInterval = interval,
|
||||
MoveSourcesToOriginals = MoveSourcesBox.IsChecked == true,
|
||||
};
|
||||
}
|
||||
|
||||
private void ReplaceInputs(IReadOnlyList<string> paths)
|
||||
@@ -325,19 +327,21 @@ public sealed partial class MainPage : Page
|
||||
|
||||
private void SaveSettings()
|
||||
{
|
||||
AppSettingsStore.Save(new AppSettings(
|
||||
OutputFolderBox.Text.Trim(),
|
||||
EndCardBox.Text.Trim(),
|
||||
FfmpegPathBox.Text.Trim(),
|
||||
FfprobePathBox.Text.Trim(),
|
||||
PreviewPlayerPathBox.Text.Trim(),
|
||||
SelectedTheme(),
|
||||
SelectedEncoder(),
|
||||
TrimBox.Text.Trim(),
|
||||
FadeBox.Text.Trim(),
|
||||
HoldBox.Text.Trim(),
|
||||
IntervalBox.Text.Trim(),
|
||||
MoveSourcesBox.IsChecked == true));
|
||||
AppSettingsStore.Save(new AppSettings
|
||||
{
|
||||
OutputFolder = OutputFolderBox.Text.Trim(),
|
||||
EndCardPath = EndCardBox.Text.Trim(),
|
||||
FfmpegPath = FfmpegPathBox.Text.Trim(),
|
||||
FfprobePath = FfprobePathBox.Text.Trim(),
|
||||
PreviewPlayerPath = PreviewPlayerPathBox.Text.Trim(),
|
||||
Theme = SelectedTheme(),
|
||||
Encoder = SelectedEncoder(),
|
||||
TrimStart = TrimBox.Text.Trim(),
|
||||
FadeSeconds = FadeBox.Text.Trim(),
|
||||
EndCardHoldSeconds = HoldBox.Text.Trim(),
|
||||
ThumbnailInterval = IntervalBox.Text.Trim(),
|
||||
MoveSourcesToOriginals = MoveSourcesBox.IsChecked == true,
|
||||
});
|
||||
}
|
||||
|
||||
private string SelectedTheme() => (ThemeBox.SelectedItem as ComboBoxItem)?.Tag?.ToString() ?? "Dark";
|
||||
|
||||
Reference in New Issue
Block a user