|
|
@ -1,156 +1,155 @@
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using Marr.Data;
|
|
|
|
using Marr.Data;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
|
|
|
using NzbDrone.Core.MediaFiles.TrackImport.Specifications;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using NzbDrone.Core.Profiles;
|
|
|
|
using NzbDrone.Core.Profiles;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
using NzbDrone.Core.Music;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
|
|
|
namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
[TestFixture]
|
|
|
|
public class UpgradeSpecificationFixture : CoreTest<UpgradeSpecification>
|
|
|
|
public class UpgradeSpecificationFixture : CoreTest<UpgradeSpecification>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private Series _series;
|
|
|
|
private Artist _artist;
|
|
|
|
private LocalEpisode _localEpisode;
|
|
|
|
private LocalTrack _localTrack;
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_series = Builder<Series>.CreateNew()
|
|
|
|
_artist = Builder<Artist>.CreateNew()
|
|
|
|
.With(s => s.SeriesType = SeriesTypes.Standard)
|
|
|
|
|
|
|
|
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
|
|
|
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
_localEpisode = new LocalEpisode
|
|
|
|
_localTrack = new LocalTrack
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi",
|
|
|
|
Path = @"C:\Test\Imagine Dragons\Imagine.Dragons.Song.1.mp3",
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1)),
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1)),
|
|
|
|
Series = _series
|
|
|
|
Artist = _artist
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_true_if_no_existing_episodeFile()
|
|
|
|
public void should_return_true_if_no_existing_trackFile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(1)
|
|
|
|
.All()
|
|
|
|
.All()
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
.With(e => e.TrackFileId = 0)
|
|
|
|
.With(e => e.EpisodeFile = null)
|
|
|
|
.With(e => e.TrackFile = null)
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
|
|
|
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_true_if_no_existing_episodeFile_for_multi_episodes()
|
|
|
|
public void should_return_true_if_no_existing_trackFile_for_multi_tracks()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(2)
|
|
|
|
.All()
|
|
|
|
.All()
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
.With(e => e.TrackFileId = 0)
|
|
|
|
.With(e => e.EpisodeFile = null)
|
|
|
|
.With(e => e.TrackFile = null)
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
|
|
|
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_true_if_upgrade_for_existing_episodeFile()
|
|
|
|
public void should_return_true_if_upgrade_for_existing_trackFile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(1)
|
|
|
|
.All()
|
|
|
|
.All()
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
.With(e => e.TrackFileId = 1)
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
|
|
|
new EpisodeFile
|
|
|
|
new TrackFile
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1))
|
|
|
|
Quality = new QualityModel(Quality.MP3_192, new Revision(version: 1))
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
|
|
|
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_true_if_upgrade_for_existing_episodeFile_for_multi_episodes()
|
|
|
|
public void should_return_true_if_upgrade_for_existing_trackFile_for_multi_tracks()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(2)
|
|
|
|
.All()
|
|
|
|
.All()
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
.With(e => e.TrackFileId = 1)
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
|
|
|
new EpisodeFile
|
|
|
|
new TrackFile
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1))
|
|
|
|
Quality = new QualityModel(Quality.MP3_192, new Revision(version: 1))
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeTrue();
|
|
|
|
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_false_if_not_an_upgrade_for_existing_episodeFile()
|
|
|
|
public void should_return_false_if_not_an_upgrade_for_existing_trackFile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(1)
|
|
|
|
.All()
|
|
|
|
.All()
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
.With(e => e.TrackFileId = 1)
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
|
|
|
new EpisodeFile
|
|
|
|
new TrackFile
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1))
|
|
|
|
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1))
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
|
|
|
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_false_if_not_an_upgrade_for_existing_episodeFile_for_multi_episodes()
|
|
|
|
public void should_return_false_if_not_an_upgrade_for_existing_trackFile_for_multi_tracks()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(2)
|
|
|
|
.All()
|
|
|
|
.All()
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
.With(e => e.TrackFileId = 1)
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
|
|
|
new EpisodeFile
|
|
|
|
new TrackFile
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1))
|
|
|
|
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1))
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
|
|
|
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_return_false_if_not_an_upgrade_for_one_existing_episodeFile_for_multi_episode()
|
|
|
|
public void should_return_false_if_not_an_upgrade_for_one_existing_trackFile_for_multi_track()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(2)
|
|
|
|
.TheFirst(1)
|
|
|
|
.TheFirst(1)
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
.With(e => e.TrackFileId = 1)
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
|
|
|
new EpisodeFile
|
|
|
|
new TrackFile
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1))
|
|
|
|
Quality = new QualityModel(Quality.MP3_192, new Revision(version: 1))
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.TheNext(1)
|
|
|
|
.TheNext(1)
|
|
|
|
.With(e => e.EpisodeFileId = 2)
|
|
|
|
.With(e => e.TrackFileId = 2)
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
|
|
|
new EpisodeFile
|
|
|
|
new TrackFile
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1))
|
|
|
|
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1))
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.Build()
|
|
|
|
.Build()
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Accepted.Should().BeFalse();
|
|
|
|
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|