Bring the Video tab closer to Shorts with 4K preview stills and crop modes (none, auto, center, plus the visual editor). Settings store a default source folder so Find videos can collect output.avi sequences. Cap the FFmpeg log with auto-scroll, hide repeat spam, and show a Windows notification when a video or short finishes or fails.
157 lines
4.7 KiB
C#
157 lines
4.7 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);
|
|
Assert.AreEqual("", normalized.SourceSearchFolder);
|
|
Assert.AreEqual("Auto", normalized.VideoSourceCropMode);
|
|
Assert.AreEqual("0", normalized.VideoCropLeft);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Normalize_WithBlankVideoSourceSettings_RestoresDefaults()
|
|
{
|
|
// Arrange
|
|
AppSettings settings = AppSettings.Default(@"C:\Videos") with
|
|
{
|
|
SourceSearchFolder = null!,
|
|
VideoSourceCropMode = "",
|
|
VideoCropLeft = " ",
|
|
VideoCropRight = "",
|
|
VideoCropTop = "",
|
|
VideoCropBottom = "",
|
|
};
|
|
|
|
// Act
|
|
AppSettings normalized = settings.Normalize(@"C:\Videos");
|
|
|
|
// Assert
|
|
Assert.AreEqual("", normalized.SourceSearchFolder);
|
|
Assert.AreEqual("Auto", normalized.VideoSourceCropMode);
|
|
Assert.AreEqual("0", normalized.VideoCropLeft);
|
|
Assert.AreEqual("0", normalized.VideoCropRight);
|
|
Assert.AreEqual("0", normalized.VideoCropTop);
|
|
Assert.AreEqual("0", normalized.VideoCropBottom);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Normalize_WithSourceSearchFolder_KeepsItUnchanged()
|
|
{
|
|
// Arrange
|
|
AppSettings settings = AppSettings.Default(@"C:\Videos") with
|
|
{
|
|
SourceSearchFolder = @"D:\AmigaIntrosVideos",
|
|
VideoSourceCropMode = "Center",
|
|
VideoCropLeft = "12",
|
|
};
|
|
|
|
// Act
|
|
AppSettings normalized = settings.Normalize(@"C:\Videos");
|
|
|
|
// Assert
|
|
Assert.AreEqual(@"D:\AmigaIntrosVideos", normalized.SourceSearchFolder);
|
|
Assert.AreEqual("Center", normalized.VideoSourceCropMode);
|
|
Assert.AreEqual("12", normalized.VideoCropLeft);
|
|
}
|
|
|
|
[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);
|
|
}
|
|
}
|