Fixed: Ensure AudioTag years have default values (#1272)

* Fixed: Ensure AudioTagService years have default values

* Fix AudioTagServiceFixture.cs tests

Co-authored-by: Sean Anderson <sean.anderson@gaiaresources.com.au>
pull/1268/head
Sean A 3 years ago committed by GitHub
parent d14a64caf9
commit 27259c1ebd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,14 +17,13 @@ using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
{
[TestFixture]
[Ignore("Readarr doesn't currently support audio")]
public class AudioTagServiceFixture : CoreTest<AudioTagService>
{
public static class TestCaseFactory
{
private static readonly string[] MediaFiles = new[] { "nin.mp2", "nin.mp3", "nin.flac", "nin.m4a", "nin.wma", "nin.ape", "nin.opus" };
private static readonly string[] SkipProperties = new[] { "IsValid", "Duration", "Quality", "MediaInfo", "ImageFile" };
private static readonly string[] SkipProperties = new[] { "IsValid", "Duration", "Quality", "MediaInfo", "ImageFile", "BookAuthors" };
private static readonly Dictionary<string, string[]> SkipPropertiesByFile = new Dictionary<string, string[]>
{
{ "nin.mp2", new[] { "OriginalReleaseDate" } }
@ -194,6 +193,9 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
var writtentags = Subject.ReadAudioTag(path);
VerifySame(writtentags, _testTags, skipProperties);
writtentags.BookAuthors.Should().BeEquivalentTo(
_testTags.BookAuthors.Concat(_testTags.Performers),
options => options.WithStrictOrdering());
}
[Test]
@ -337,12 +339,12 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
[Test]
public void should_not_fail_if_media_has_been_omitted()
{
// make sure that we aren't relying on index of items in
// Media being the same as the medium number
GivenFileCopy("nin.mp3");
var file = GivenPopulatedTrackfile(100);
var tag = Subject.GetTrackMetadata(file);
file.Path = _copiedFile;
tag.Media.Should().NotBeNull();
Assert.DoesNotThrow(() => Subject.GetTrackMetadata(file));
}
[TestCase("nin.mp3")]
@ -363,5 +365,18 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
file.Modified.Should().Be(fileInfo.LastWriteTimeUtc);
file.Size.Should().Be(fileInfo.Length);
}
[Test]
public void should_not_fail_reading_metadata_with_dates_omitted()
{
GivenFileCopy("nin.mp3");
var bookFile = GivenPopulatedTrackfile(0);
bookFile.Path = _copiedFile;
bookFile.Edition.Value.ReleaseDate = null;
bookFile.Edition.Value.Book.Value.ReleaseDate = null;
Assert.DoesNotThrow(() => Subject.GetTrackMetadata(bookFile));
}
}
}

@ -108,9 +108,9 @@ namespace NzbDrone.Core.MediaFiles
// We may have omitted media so index in the list isn't the same as medium number
Media = fileTags.Media,
Date = edition.ReleaseDate,
Year = (uint)edition.ReleaseDate?.Year,
Year = (uint)(edition.ReleaseDate?.Year ?? 0),
OriginalReleaseDate = book.ReleaseDate,
OriginalYear = (uint)book.ReleaseDate?.Year,
OriginalYear = (uint)(book.ReleaseDate?.Year ?? 0),
Publisher = edition.Publisher,
Genres = new string[0],
ImageFile = imageFile,

Loading…
Cancel
Save