Radarr/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/UpdateMediaInfoServiceFixtu...

292 lines
9.6 KiB
C#
Raw Normal View History

2014-07-23 23:43:54 +00:00
using System.IO;
using FizzWare.NBuilder;
2019-07-27 04:33:04 +00:00
using FluentAssertions;
2014-04-10 17:58:50 +00:00
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
2014-04-10 17:58:50 +00:00
using NzbDrone.Test.Common;
using NzbDrone.Core.Configuration;
2014-04-10 17:58:50 +00:00
namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
{
[TestFixture]
public class UpdateMediaInfoServiceFixture : CoreTest<UpdateMediaInfoService>
{
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
private Movie _movie;
2014-07-23 23:43:54 +00:00
[SetUp]
public void Setup()
{
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
_movie = new Movie
2014-07-23 23:43:54 +00:00
{
Id = 1,
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
Path = @"C:\movie".AsOsAgnostic()
2014-07-23 23:43:54 +00:00
};
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.EnableMediaInfo)
.Returns(true);
2014-07-23 23:43:54 +00:00
}
2014-04-10 17:58:50 +00:00
private void GivenFileExists()
{
Mocker.GetMock<IDiskProvider>()
.Setup(v => v.FileExists(It.IsAny<string>()))
2014-04-10 17:58:50 +00:00
.Returns(true);
}
private void GivenSuccessfulScan()
{
Mocker.GetMock<IVideoFileInfoReader>()
.Setup(v => v.GetMediaInfo(It.IsAny<string>()))
2014-04-10 17:58:50 +00:00
.Returns(new MediaInfoModel());
}
private void GivenFailedScan(string path)
2014-04-10 17:58:50 +00:00
{
Mocker.GetMock<IVideoFileInfoReader>()
.Setup(v => v.GetMediaInfo(path))
.Returns((MediaInfoModel)null);
}
[Test]
2016-08-11 23:20:40 +00:00
public void should_skip_up_to_date_media_info()
2014-04-10 17:58:50 +00:00
{
2019-07-27 04:33:04 +00:00
var movieFiles = Builder<MovieFile>.CreateListOfSize(3)
2014-04-10 17:58:50 +00:00
.All()
2014-07-23 23:43:54 +00:00
.With(v => v.RelativePath = "media.mkv")
2014-04-10 17:58:50 +00:00
.TheFirst(1)
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
2014-04-10 17:58:50 +00:00
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesByMovie(1))
2019-07-27 04:33:04 +00:00
.Returns(movieFiles);
2014-04-10 17:58:50 +00:00
GivenFileExists();
GivenSuccessfulScan();
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
Subject.Handle(new MovieScannedEvent(_movie));
2014-04-10 17:58:50 +00:00
Mocker.GetMock<IVideoFileInfoReader>()
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
.Verify(v => v.GetMediaInfo(Path.Combine(_movie.Path, "media.mkv")), Times.Exactly(2));
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(2));
}
[Test]
public void should_skip_not_yet_date_media_info()
{
2019-07-27 04:33:04 +00:00
var movieFiles = Builder<MovieFile>.CreateListOfSize(3)
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesByMovie(1))
2019-07-27 04:33:04 +00:00
.Returns(movieFiles);
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
GivenFileExists();
GivenSuccessfulScan();
Subject.Handle(new MovieScannedEvent(_movie));
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(Path.Combine(_movie.Path, "media.mkv")), Times.Exactly(2));
2014-04-10 17:58:50 +00:00
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(2));
2014-04-10 17:58:50 +00:00
}
2016-08-11 23:20:40 +00:00
[Test]
public void should_update_outdated_media_info()
{
2019-07-27 04:33:04 +00:00
var movieFiles = Builder<MovieFile>.CreateListOfSize(3)
2016-08-11 23:20:40 +00:00
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel())
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesByMovie(1))
2019-07-27 04:33:04 +00:00
.Returns(movieFiles);
2016-08-11 23:20:40 +00:00
GivenFileExists();
GivenSuccessfulScan();
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
Subject.Handle(new MovieScannedEvent(_movie));
2016-08-11 23:20:40 +00:00
Mocker.GetMock<IVideoFileInfoReader>()
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
.Verify(v => v.GetMediaInfo(Path.Combine(_movie.Path, "media.mkv")), Times.Exactly(3));
2016-08-11 23:20:40 +00:00
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(3));
2016-08-11 23:20:40 +00:00
}
2014-04-10 17:58:50 +00:00
[Test]
public void should_ignore_missing_files()
{
2019-07-27 04:33:04 +00:00
var movieFiles = Builder<MovieFile>.CreateListOfSize(2)
2014-04-10 17:58:50 +00:00
.All()
2014-07-23 23:43:54 +00:00
.With(v => v.RelativePath = "media.mkv")
2014-04-10 17:58:50 +00:00
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesByMovie(1))
2019-07-27 04:33:04 +00:00
.Returns(movieFiles);
2014-04-10 17:58:50 +00:00
GivenSuccessfulScan();
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
Subject.Handle(new MovieScannedEvent(_movie));
2014-04-10 17:58:50 +00:00
Mocker.GetMock<IVideoFileInfoReader>()
2014-07-23 23:43:54 +00:00
.Verify(v => v.GetMediaInfo("media.mkv"), Times.Never());
2014-04-10 17:58:50 +00:00
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Never());
2014-04-10 17:58:50 +00:00
}
[Test]
public void should_continue_after_failure()
{
2019-07-27 04:33:04 +00:00
var movieFiles = Builder<MovieFile>.CreateListOfSize(2)
2014-04-10 17:58:50 +00:00
.All()
2014-07-23 23:43:54 +00:00
.With(v => v.RelativePath = "media.mkv")
2014-04-10 17:58:50 +00:00
.TheFirst(1)
2014-07-23 23:43:54 +00:00
.With(v => v.RelativePath = "media2.mkv")
2014-04-10 17:58:50 +00:00
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesByMovie(1))
2019-07-27 04:33:04 +00:00
.Returns(movieFiles);
2014-04-10 17:58:50 +00:00
GivenFileExists();
GivenSuccessfulScan();
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
GivenFailedScan(Path.Combine(_movie.Path, "media2.mkv"));
2014-04-10 17:58:50 +00:00
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
Subject.Handle(new MovieScannedEvent(_movie));
2014-04-10 17:58:50 +00:00
Mocker.GetMock<IVideoFileInfoReader>()
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
2018-10-30 20:44:59 +00:00
.Verify(v => v.GetMediaInfo(Path.Combine(_movie.Path, "media.mkv")), Times.Exactly(1));
2014-04-10 17:58:50 +00:00
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Exactly(1));
2014-04-10 17:58:50 +00:00
}
2019-07-27 04:33:04 +00:00
[Test]
public void should_not_update_files_if_media_info_disabled()
{
var movieFiles = Builder<MovieFile>.CreateListOfSize(2)
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.RelativePath = "media2.mkv")
.BuildList();
Mocker.GetMock<IMediaFileService>()
.Setup(v => v.GetFilesByMovie(1))
.Returns(movieFiles);
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.EnableMediaInfo)
.Returns(false);
2019-12-22 21:24:11 +00:00
2019-07-27 04:33:04 +00:00
GivenFileExists();
GivenSuccessfulScan();
Subject.Handle(new MovieScannedEvent(_movie));
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(It.IsAny<string>()), Times.Never());
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Never());
}
[Test]
public void should_not_update_if_media_info_disabled()
{
var movieFile = Builder<MovieFile>.CreateNew()
.With(v => v.RelativePath = "media.mkv")
.Build();
Mocker.GetMock<IConfigService>()
.SetupGet(s => s.EnableMediaInfo)
.Returns(false);
2019-12-22 21:24:11 +00:00
2019-07-27 04:33:04 +00:00
GivenFileExists();
GivenSuccessfulScan();
Subject.Update(movieFile, _movie);
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(It.IsAny<string>()), Times.Never());
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(It.IsAny<MovieFile>()), Times.Never());
}
[Test]
public void should_update_media_info()
{
var movieFile = Builder<MovieFile>.CreateNew()
.With(v => v.RelativePath = "media.mkv")
.With(e => e.MediaInfo = new MediaInfoModel{SchemaRevision = 3})
.Build();
GivenFileExists();
GivenSuccessfulScan();
Subject.Update(movieFile, _movie);
Mocker.GetMock<IVideoFileInfoReader>()
.Verify(v => v.GetMediaInfo(Path.Combine(_movie.Path, "media.mkv")), Times.Once());
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(movieFile), Times.Once());
}
2019-12-22 21:24:11 +00:00
2019-07-27 04:33:04 +00:00
[Test]
public void should_not_update_media_info_if_new_info_is_null()
{
var movieFile = Builder<MovieFile>.CreateNew()
.With(v => v.RelativePath = "media.mkv")
.With(e => e.MediaInfo = new MediaInfoModel{SchemaRevision = 3})
.Build();
GivenFileExists();
GivenFailedScan(Path.Combine(_movie.Path, "media.mkv"));
Subject.Update(movieFile, _movie);
movieFile.MediaInfo.Should().NotBeNull();
}
2019-12-22 21:24:11 +00:00
2019-07-27 04:33:04 +00:00
[Test]
public void should_not_save_movie_file_if_new_info_is_null()
{
var movieFile = Builder<MovieFile>.CreateNew()
.With(v => v.RelativePath = "media.mkv")
.With(e => e.MediaInfo = new MediaInfoModel{SchemaRevision = 3})
.Build();
GivenFileExists();
GivenFailedScan(Path.Combine(_movie.Path, "media.mkv"));
Subject.Update(movieFile, _movie);
Mocker.GetMock<IMediaFileService>()
.Verify(v => v.Update(movieFile), Times.Never());
}
2014-04-10 17:58:50 +00:00
}
}