diff --git a/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs b/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs index 51773823..0f7a9648 100644 --- a/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs +++ b/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs @@ -44,9 +44,9 @@ namespace TemplatesTests AudibleProductId = "asin", Title = "A Study in Scarlet: A Sherlock Holmes Novel", Locale = "us", - YearPublished = 2017, + YearPublished = null, // explicitly null Authors = [new("Arthur Conan Doyle", "B000AQ43GQ"), new("Stephen Fry - introductions", "B000APAGVS")], - Narrators = [new("Stephen Fry", "B000APAGVS"), new("Some Narrator", "B000000000")], + Narrators = [], // explicitly empty list Series = series, BitRate = 128, SampleRate = 44100, @@ -55,8 +55,8 @@ namespace TemplatesTests Subtitle = "An Audible Original Drama", TitleWithSubtitle = "A Study in Scarlet: An Audible Original Drama", Codec = "AAC-LC", - FileVersion = "1.0", - LibationVersion = "1.0.0", + FileVersion = null, // explicitly null + LibationVersion = "", // explicitly empty string }; } @@ -103,8 +103,8 @@ namespace TemplatesTests [DataRow("f", @"C:\foo\bar", ".ext", @"C:\foo\bar\f.ext")] [DataRow("", @"C:\foo\bar", ".ext", @"C:\foo\bar\asin.ext")] [DataRow(" - - ", @"C:\foo\bar", ".ext", @"C:\foo\bar\128 - 44100 - 2.ext")] - [DataRow(" - ", @"C:\foo\bar", ".ext", @"C:\foo\bar\2017 - 2.ext")] - [DataRow("(000.0) - ", @"C:\foo\bar", "ext", @"C:\foo\bar\(000.0) 2017 - 2.ext")] + [DataRow(" - ", @"C:\foo\bar", ".ext", @"C:\foo\bar\- 2.ext")] + [DataRow("(000.0) - ", @"C:\foo\bar", "ext", @"C:\foo\bar\(000.0) - 2.ext")] public void Tests(string template, string dirFullPath, string extension, string expected) { if (Environment.OSVersion.Platform is not PlatformID.Win32NT) @@ -173,6 +173,21 @@ namespace TemplatesTests fileTemplate.GetFilename(GetLibraryBook(), "", "", culture: null, replacements: Replacements).PathWithoutPrefix.Should().Be(expected); } + [TestMethod] + [DataRow("", "")] + [DataRow("", "")] + [DataRow("", "")] + [DataRow("", "")] + [DataRow("", "")] + [DataRow("", "")] + public void EmptyFields(string template, string expected) + { + var bookDto = GetLibraryBook(); + + Templates.TryGetTemplate(template, out var fileTemplate).Should().BeTrue(); + fileTemplate.GetFilename(bookDto, "", "", Replacements).PathWithoutPrefix.Should().Be(expected); + } + [TestMethod] [DataRow(" - ", @"C:\foo\bar", "m4b", @"C:\foo\bar\asin - 23-01-28.m4b")] [DataRow(" - ", @"C:\foo\bar", "m4b", @"C:\foo\bar\asin - 23-01-28.m4b")] @@ -383,7 +398,12 @@ namespace TemplatesTests } [TestMethod] + [DataRow("empty-string<-has>", "")] + [DataRow("null-string<-has>", "")] + [DataRow("null-int<-has>", "")] [DataRow("unknown-tag<-has>", "")] + [DataRow("empty-list<-has>", "")] + [DataRow("no-first<-has>", "")] public void HasValue_on_empty_test(string template, string expected) { var bookDto = GetLibraryBook(); @@ -410,8 +430,6 @@ namespace TemplatesTests [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] - [DataRow("true<-has>", "true")] - [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] @@ -419,12 +437,9 @@ namespace TemplatesTests [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] - [DataRow("true<-has>", "true")] - [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] - [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")] [DataRow("true<-has>", "true")]