From bfbdba14f6259dd258466a3a9f103ac11cf630b1 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 24 Dec 2017 00:03:38 -0500 Subject: [PATCH] Fixed: ImportApprovedTracksFixture Tests --- ...ture.cs => ImportApprovedTracksFixture.cs} | 87 ++++--------------- .../NzbDrone.Core.Test.csproj | 2 +- 2 files changed, 20 insertions(+), 69 deletions(-) rename src/NzbDrone.Core.Test/MediaFiles/{ImportApprovedEpisodesFixture.cs => ImportApprovedTracksFixture.cs} (69%) diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs similarity index 69% rename from src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs rename to src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs index 200b7a9ec..aebd2212e 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs @@ -23,7 +23,7 @@ using NzbDrone.Core.Profiles.Languages; namespace NzbDrone.Core.Test.MediaFiles { [TestFixture] - public class ImportApprovedEpisodesFixture : CoreTest + public class ImportApprovedTracksFixture : CoreTest { private List _rejectedDecisions; private List _approvedDecisions; @@ -46,6 +46,11 @@ namespace NzbDrone.Core.Test.MediaFiles .With(s => s.Path = @"C:\Test\Music\Alien Ant Farm".AsOsAgnostic()) .Build(); + var album = Builder.CreateNew() + .With(e => e.Artist = artist) + .Build(); + + var tracks = Builder.CreateListOfSize(5) .Build(); @@ -62,8 +67,9 @@ namespace NzbDrone.Core.Test.MediaFiles new LocalTrack { Artist = artist, + Album = album, Tracks = new List { track }, - Path = Path.Combine(artist.Path, "30 Rock - S01E01 - Pilot.avi"), + Path = Path.Combine(artist.Path, "Alien Ant Farm - 01 - Pilot.mp3"), Quality = new QualityModel(Quality.MP3_256), ParsedTrackInfo = new ParsedTrackInfo { @@ -107,7 +113,7 @@ namespace NzbDrone.Core.Test.MediaFiles } [Test] - public void should_only_import_each_episode_once() + public void should_only_import_each_track_once() { var all = new List(); all.AddRange(_approvedDecisions); @@ -128,14 +134,14 @@ namespace NzbDrone.Core.Test.MediaFiles Times.Once()); } - //[Test] - //public void should_publish_EpisodeImportedEvent_for_new_downloads() - //{ - // Subject.Import(new List { _approvedDecisions.First() }, true); + [Test] + public void should_publish_TrackImportedEvent_for_new_downloads() + { + Subject.Import(new List { _approvedDecisions.First() }, true); - // Mocker.GetMock() - // .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); - //} + Mocker.GetMock() + .Verify(v => v.PublishEvent(It.IsAny()), Times.Once()); + } [Test] public void should_not_move_existing_files() @@ -147,61 +153,6 @@ namespace NzbDrone.Core.Test.MediaFiles Times.Never()); } - [Test] - public void should_use_nzb_title_as_scene_name() - { - _downloadClientItem.Title = "malcolm.in.the.middle.s02e05.dvdrip.xvid-ingot"; - - Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); - - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == _downloadClientItem.Title))); - } - - [TestCase(".mkv")] - [TestCase(".par2")] - [TestCase(".nzb")] - public void should_remove_extension_from_nzb_title_for_scene_name(string extension) - { - var title = "malcolm.in.the.middle.s02e05.dvdrip.xvid-ingot"; - - _downloadClientItem.Title = title + extension; - - Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); - - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == title))); - } - - [Test] - public void should_not_use_nzb_title_as_scene_name_if_full_season() - { - _approvedDecisions.First().LocalTrack.Path = "c:\\tv\\season1\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic(); - _downloadClientItem.Title = "malcolm.in.the.middle.s02.dvdrip.xvid-ingot"; - - Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); - - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); - } - - [Test] - public void should_use_file_name_as_scenename_only_if_it_looks_like_scenename() - { - _approvedDecisions.First().LocalTrack.Path = "c:\\tv\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic(); - - Subject.Import(new List { _approvedDecisions.First() }, true); - - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); - } - - [Test] - public void should_not_use_file_name_as_scenename_if_it_doesnt_looks_like_scenename() - { - _approvedDecisions.First().LocalTrack.Path = "c:\\tv\\aaaaa.mkv".AsOsAgnostic(); - - Subject.Import(new List { _approvedDecisions.First() }, true); - - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == null))); - } - [Test] public void should_import_larger_files_first() { @@ -213,7 +164,7 @@ namespace NzbDrone.Core.Test.MediaFiles { Artist = fileDecision.LocalTrack.Artist, Tracks = new List { fileDecision.LocalTrack.Tracks.First() }, - Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilot.avi".AsOsAgnostic(), + Path = @"C:\Test\Music\Alien Ant Farm\Alien Ant Farm - 01 - Pilot.mp3".AsOsAgnostic(), Quality = new QualityModel(Quality.MP3_256), Size = 80.Megabytes() }); @@ -233,7 +184,7 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_copy_when_cannot_move_files_downloads() { - Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", CanMoveFiles = false }); + Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }); Mocker.GetMock() .Verify(v => v.UpgradeTrackFile(It.IsAny(), _approvedDecisions.First().LocalTrack, true), Times.Once()); @@ -242,7 +193,7 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_use_override_importmode() { - Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", CanMoveFiles = false }, ImportMode.Move); + Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }, ImportMode.Move); Mocker.GetMock() .Verify(v => v.UpgradeTrackFile(It.IsAny(), _approvedDecisions.First().LocalTrack, false), Times.Once()); diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 4702e530c..d720fefb2 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -266,7 +266,7 @@ - +