c412469773
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>
108 lines
3.0 KiB
C#
108 lines
3.0 KiB
C#
using AmiReel.Models;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace AmiReel.Tests.Models;
|
|
|
|
[TestClass]
|
|
public class AppSettingsTests
|
|
{
|
|
[TestMethod]
|
|
public void Default_SetsFallbackOutputFolderAndSensibleDefaults()
|
|
{
|
|
// Arrange
|
|
const string outputFolder = @"C:\Videos";
|
|
|
|
// Act
|
|
AppSettings settings = AppSettings.Default(outputFolder);
|
|
|
|
// Assert
|
|
Assert.AreEqual(outputFolder, settings.OutputFolder);
|
|
Assert.AreEqual("Dark", settings.Theme);
|
|
Assert.AreEqual("Auto", settings.Encoder);
|
|
Assert.IsTrue(settings.ShouldMoveSourcesToOriginals);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ShouldMoveSourcesToOriginals_WhenFlagIsNull_DefaultsToTrue()
|
|
{
|
|
// Arrange
|
|
AppSettings settings = AppSettings.Default(@"C:\Videos") with { MoveSourcesToOriginals = null };
|
|
|
|
// Act
|
|
bool result = settings.ShouldMoveSourcesToOriginals;
|
|
|
|
// Assert
|
|
Assert.IsTrue(result);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ShouldMoveSourcesToOriginals_WhenFlagIsExplicitlyFalse_ReturnsFalse()
|
|
{
|
|
// Arrange
|
|
AppSettings settings = AppSettings.Default(@"C:\Videos") with { MoveSourcesToOriginals = false };
|
|
|
|
// Act
|
|
bool result = settings.ShouldMoveSourcesToOriginals;
|
|
|
|
// Assert
|
|
Assert.IsFalse(result);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Normalize_WithBlankOutputFolder_UsesFallback()
|
|
{
|
|
// Arrange
|
|
AppSettings settings = AppSettings.Default("") with { OutputFolder = " " };
|
|
|
|
// Act
|
|
AppSettings normalized = settings.Normalize(@"C:\Fallback");
|
|
|
|
// Assert
|
|
Assert.AreEqual(@"C:\Fallback", normalized.OutputFolder);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Normalize_WithBlankTimingValues_RestoresDefaults()
|
|
{
|
|
// Arrange
|
|
AppSettings settings = AppSettings.Default(@"C:\Videos") with
|
|
{
|
|
TrimStart = "",
|
|
FadeSeconds = " ",
|
|
EndCardHoldSeconds = "",
|
|
ThumbnailInterval = "",
|
|
};
|
|
|
|
// Act
|
|
AppSettings normalized = settings.Normalize(@"C:\Videos");
|
|
|
|
// Assert
|
|
Assert.AreEqual("4.414", normalized.TrimStart);
|
|
Assert.AreEqual("3", normalized.FadeSeconds);
|
|
Assert.AreEqual("4", normalized.EndCardHoldSeconds);
|
|
Assert.AreEqual("10", normalized.ThumbnailInterval);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Normalize_WithPopulatedValues_KeepsThemUnchanged()
|
|
{
|
|
// Arrange
|
|
AppSettings settings = AppSettings.Default(@"C:\Videos") with
|
|
{
|
|
TrimStart = "1.5",
|
|
FadeSeconds = "2.5",
|
|
Theme = "Light",
|
|
Encoder = "NvidiaNvenc",
|
|
};
|
|
|
|
// Act
|
|
AppSettings normalized = settings.Normalize(@"C:\Videos");
|
|
|
|
// Assert
|
|
Assert.AreEqual("1.5", normalized.TrimStart);
|
|
Assert.AreEqual("2.5", normalized.FadeSeconds);
|
|
Assert.AreEqual("Light", normalized.Theme);
|
|
Assert.AreEqual("NvidiaNvenc", normalized.Encoder);
|
|
}
|
|
}
|