mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
@@ -5,10 +5,10 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -19,18 +19,20 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
private const int HIGH_KBPS_BITRATE = 1600;
|
||||
private const int TWENTY_MINUTE_EP_MILLIS = 20 * 60 * 1000;
|
||||
private const int FORTY_FIVE_MINUTE_LP_MILLIS = 45 * 60 * 1000;
|
||||
private RemoteAlbum parseResultMultiSet;
|
||||
private RemoteAlbum parseResultMulti;
|
||||
private RemoteAlbum parseResultSingle;
|
||||
private Artist artist;
|
||||
private QualityDefinition qualityType;
|
||||
private RemoteAlbum _parseResultMultiSet;
|
||||
private RemoteAlbum _parseResultMulti;
|
||||
private RemoteAlbum _parseResultSingle;
|
||||
private Artist _artist;
|
||||
private QualityDefinition _qualityType;
|
||||
|
||||
private Album AlbumBuilder(int id = 0)
|
||||
{
|
||||
return new Album
|
||||
{
|
||||
Id = id,
|
||||
AlbumReleases = new List<AlbumRelease> { new AlbumRelease
|
||||
AlbumReleases = new List<AlbumRelease>
|
||||
{
|
||||
new AlbumRelease
|
||||
{
|
||||
Duration = 0,
|
||||
Monitored = true
|
||||
@@ -42,60 +44,63 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
artist = Builder<Artist>.CreateNew()
|
||||
_artist = Builder<Artist>.CreateNew()
|
||||
.Build();
|
||||
|
||||
parseResultMultiSet = new RemoteAlbum
|
||||
_parseResultMultiSet = new RemoteAlbum
|
||||
{
|
||||
Artist = artist,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||
Albums = new List<Album> { AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder() }
|
||||
};
|
||||
Artist = _artist,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||
Albums = new List<Album> { AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder() }
|
||||
};
|
||||
|
||||
parseResultMulti = new RemoteAlbum
|
||||
_parseResultMulti = new RemoteAlbum
|
||||
{
|
||||
Artist = artist,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||
Albums = new List<Album> { AlbumBuilder(), AlbumBuilder() }
|
||||
};
|
||||
Artist = _artist,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||
Albums = new List<Album> { AlbumBuilder(), AlbumBuilder() }
|
||||
};
|
||||
|
||||
parseResultSingle = new RemoteAlbum
|
||||
_parseResultSingle = new RemoteAlbum
|
||||
{
|
||||
Artist = artist,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||
Albums = new List<Album> { AlbumBuilder(2) }
|
||||
|
||||
};
|
||||
Artist = _artist,
|
||||
Release = new ReleaseInfo(),
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||
Albums = new List<Album> { AlbumBuilder(2) }
|
||||
};
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>()
|
||||
.Setup(v => v.Get(It.IsAny<Quality>()))
|
||||
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
|
||||
|
||||
qualityType = Builder<QualityDefinition>.CreateNew()
|
||||
_qualityType = Builder<QualityDefinition>.CreateNew()
|
||||
.With(q => q.MinSize = 150)
|
||||
.With(q => q.MaxSize = 210)
|
||||
.With(q => q.Quality = Quality.MP3_192)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.MP3_192)).Returns(qualityType);
|
||||
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.MP3_192)).Returns(_qualityType);
|
||||
|
||||
Mocker.GetMock<IAlbumService>().Setup(
|
||||
s => s.GetAlbumsByArtist(It.IsAny<int>()))
|
||||
.Returns(new List<Album>() {
|
||||
.Returns(new List<Album>()
|
||||
{
|
||||
AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(),
|
||||
AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(2), AlbumBuilder() });
|
||||
AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(2), AlbumBuilder()
|
||||
});
|
||||
}
|
||||
|
||||
private void GivenLastAlbum()
|
||||
{
|
||||
Mocker.GetMock<IAlbumService>().Setup(
|
||||
s => s.GetAlbumsByArtist(It.IsAny<int>()))
|
||||
.Returns(new List<Album> {
|
||||
.Returns(new List<Album>
|
||||
{
|
||||
AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(),
|
||||
AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(2) });
|
||||
AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(), AlbumBuilder(2)
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 20, false)]
|
||||
@@ -106,11 +111,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 75, false)]
|
||||
public void single_album(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
parseResultSingle.Albums.Select(c => { c.AlbumReleases.Value[0].Duration = runtime; return c; }).ToList();
|
||||
parseResultSingle.Artist = artist;
|
||||
parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
_parseResultSingle.Albums.Select(c =>
|
||||
{
|
||||
c.AlbumReleases.Value[0].Duration = runtime;
|
||||
return c;
|
||||
}).ToList();
|
||||
_parseResultSingle.Artist = _artist;
|
||||
_parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().Be(expectedResult);
|
||||
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 20 * 2, false)]
|
||||
@@ -121,11 +130,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 75 * 2, false)]
|
||||
public void multi_album(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
parseResultMulti.Albums.Select(c => { c.AlbumReleases.Value[0].Duration = runtime; return c; }).ToList();
|
||||
parseResultMulti.Artist = artist;
|
||||
parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
_parseResultMulti.Albums.Select(c =>
|
||||
{
|
||||
c.AlbumReleases.Value[0].Duration = runtime;
|
||||
return c;
|
||||
}).ToList();
|
||||
_parseResultMulti.Artist = _artist;
|
||||
_parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultMulti, null).Accepted.Should().Be(expectedResult);
|
||||
Subject.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[TestCase(TWENTY_MINUTE_EP_MILLIS, 20 * 6, false)]
|
||||
@@ -136,49 +149,64 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[TestCase(FORTY_FIVE_MINUTE_LP_MILLIS, 75 * 6, false)]
|
||||
public void multiset_album(int runtime, int sizeInMegaBytes, bool expectedResult)
|
||||
{
|
||||
parseResultMultiSet.Albums.Select(c => { c.AlbumReleases.Value[0].Duration = runtime; return c; }).ToList();
|
||||
parseResultMultiSet.Artist = artist;
|
||||
parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
_parseResultMultiSet.Albums.Select(c =>
|
||||
{
|
||||
c.AlbumReleases.Value[0].Duration = runtime;
|
||||
return c;
|
||||
}).ToList();
|
||||
_parseResultMultiSet.Artist = _artist;
|
||||
_parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultMultiSet, null).Accepted.Should().Be(expectedResult);
|
||||
Subject.IsSatisfiedBy(_parseResultMultiSet, null).Accepted.Should().Be(expectedResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_size_is_zero()
|
||||
{
|
||||
GivenLastAlbum();
|
||||
parseResultSingle.Albums.Select(c => { c.AlbumReleases.Value[0].Duration = TWENTY_MINUTE_EP_MILLIS; return c; }).ToList();
|
||||
parseResultSingle.Artist = artist;
|
||||
parseResultSingle.Release.Size = 0;
|
||||
qualityType.MinSize = 150;
|
||||
qualityType.MaxSize = 210;
|
||||
_parseResultSingle.Albums.Select(c =>
|
||||
{
|
||||
c.AlbumReleases.Value[0].Duration = TWENTY_MINUTE_EP_MILLIS;
|
||||
return c;
|
||||
}).ToList();
|
||||
_parseResultSingle.Artist = _artist;
|
||||
_parseResultSingle.Release.Size = 0;
|
||||
_qualityType.MinSize = 150;
|
||||
_qualityType.MaxSize = 210;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_unlimited_20_minute()
|
||||
{
|
||||
GivenLastAlbum();
|
||||
parseResultSingle.Albums.Select(c => { c.AlbumReleases.Value[0].Duration = TWENTY_MINUTE_EP_MILLIS; return c; }).ToList();
|
||||
parseResultSingle.Artist = artist;
|
||||
parseResultSingle.Release.Size = (HIGH_KBPS_BITRATE * 128) * (TWENTY_MINUTE_EP_MILLIS / 1000);
|
||||
qualityType.MaxSize = null;
|
||||
_parseResultSingle.Albums.Select(c =>
|
||||
{
|
||||
c.AlbumReleases.Value[0].Duration = TWENTY_MINUTE_EP_MILLIS;
|
||||
return c;
|
||||
}).ToList();
|
||||
_parseResultSingle.Artist = _artist;
|
||||
_parseResultSingle.Release.Size = (HIGH_KBPS_BITRATE * 128) * (TWENTY_MINUTE_EP_MILLIS / 1000);
|
||||
_qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_unlimited_45_minute()
|
||||
{
|
||||
GivenLastAlbum();
|
||||
parseResultSingle.Albums.Select(c => { c.AlbumReleases.Value[0].Duration = FORTY_FIVE_MINUTE_LP_MILLIS; return c; }).ToList();
|
||||
parseResultSingle.Artist = artist;
|
||||
parseResultSingle.Release.Size = (HIGH_KBPS_BITRATE * 128) * (FORTY_FIVE_MINUTE_LP_MILLIS / 1000);
|
||||
qualityType.MaxSize = null;
|
||||
_parseResultSingle.Albums.Select(c =>
|
||||
{
|
||||
c.AlbumReleases.Value[0].Duration = FORTY_FIVE_MINUTE_LP_MILLIS;
|
||||
return c;
|
||||
}).ToList();
|
||||
_parseResultSingle.Artist = _artist;
|
||||
_parseResultSingle.Release.Size = (HIGH_KBPS_BITRATE * 128) * (FORTY_FIVE_MINUTE_LP_MILLIS / 1000);
|
||||
_qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -18,7 +18,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
|
||||
{
|
||||
Cutoff = Quality.MP3_256.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
@@ -45,7 +44,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
|
||||
{
|
||||
Cutoff = Quality.MP3_256.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
@@ -59,7 +57,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
|
||||
{
|
||||
Cutoff = Quality.MP3_320.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
@@ -67,7 +64,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 1)) },
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.MP3_320, new Revision(version: 2))).Should().BeTrue();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -75,7 +71,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
|
||||
{
|
||||
Cutoff = Quality.MP3_320.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
@@ -88,32 +83,31 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_true_if_cutoffs_are_met_and_score_is_higher()
|
||||
{
|
||||
QualityProfile _profile = new QualityProfile
|
||||
QualityProfile profile = new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.MP3_320.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
};
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
_profile,
|
||||
profile,
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.FLAC, new Revision(version: 2)),
|
||||
10).Should().BeTrue();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
|
||||
{
|
||||
QualityProfile _profile = new QualityProfile
|
||||
QualityProfile profile = new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.MP3_320.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
};
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
_profile,
|
||||
profile,
|
||||
new List<QualityModel> { new QualityModel(Quality.FLAC, new Revision(version: 1)) },
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.FLAC, new Revision(version: 2)),
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using FizzWare.NBuilder;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NzbDrone.Core.Music;
|
||||
using Moq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Test.Common;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null)).Returns(Decision.Accept);
|
||||
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null)).Returns(Decision.Accept);
|
||||
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null)).Returns(Decision.Accept);
|
||||
|
||||
|
||||
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null)).Returns(Decision.Reject("fail1"));
|
||||
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null)).Returns(Decision.Reject("fail2"));
|
||||
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<RemoteAlbum>(), null)).Returns(Decision.Reject("fail3"));
|
||||
@@ -57,7 +57,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_failDelayed1.SetupGet(c => c.Priority).Returns(SpecificationPriority.Disk);
|
||||
|
||||
_reports = new List<ReleaseInfo> { new ReleaseInfo { Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT" } };
|
||||
_remoteAlbum = new RemoteAlbum {
|
||||
_remoteAlbum = new RemoteAlbum
|
||||
{
|
||||
Artist = new Artist(),
|
||||
Albums = new List<Album> { new Album() }
|
||||
};
|
||||
@@ -203,9 +204,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
_reports = new List<ReleaseInfo>
|
||||
{
|
||||
new ReleaseInfo{Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT"},
|
||||
new ReleaseInfo{Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT"},
|
||||
new ReleaseInfo{Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT"}
|
||||
new ReleaseInfo { Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT" },
|
||||
new ReleaseInfo { Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT" },
|
||||
new ReleaseInfo { Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT" }
|
||||
};
|
||||
|
||||
Subject.GetRssDecision(_reports);
|
||||
@@ -238,17 +239,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.With(v => v.Artist, new LazyLoaded<Artist>(artist))
|
||||
.BuildList();
|
||||
|
||||
var criteria = new ArtistSearchCriteria { Albums = albums.Take(1).ToList()};
|
||||
var criteria = new ArtistSearchCriteria { Albums = albums.Take(1).ToList() };
|
||||
|
||||
var reports = albums.Select(v =>
|
||||
new ReleaseInfo()
|
||||
{
|
||||
Title = string.Format("{0}-{1}[FLAC][2017][DRONE]", artist.Name, v.Title)
|
||||
var reports = albums.Select(v =>
|
||||
new ReleaseInfo()
|
||||
{
|
||||
Title = string.Format("{0}-{1}[FLAC][2017][DRONE]", artist.Name, v.Title)
|
||||
}).ToList();
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(v => v.Map(It.IsAny<ParsedAlbumInfo>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns<ParsedAlbumInfo, SearchCriteriaBase>((p,c) =>
|
||||
.Returns<ParsedAlbumInfo, SearchCriteriaBase>((p, c) =>
|
||||
new RemoteAlbum
|
||||
{
|
||||
DownloadAllowed = true,
|
||||
@@ -307,7 +308,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
_reports = new List<ReleaseInfo>
|
||||
{
|
||||
new ReleaseInfo{Title = "Alien Ant Farm - TruAnt (FLAC) DRONE"},
|
||||
new ReleaseInfo { Title = "Alien Ant Farm - TruAnt (FLAC) DRONE" },
|
||||
};
|
||||
|
||||
Subject.GetRssDecision(_reports).Should().HaveCount(1);
|
||||
|
||||
@@ -8,8 +8,8 @@ using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.TorrentRss;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
@@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_remoteAlbum = new RemoteAlbum
|
||||
{
|
||||
Artist = _artist,
|
||||
Albums = new List<Album>{_album1},
|
||||
Albums = new List<Album> { _album1 },
|
||||
Release = new TorrentInfo
|
||||
{
|
||||
IndexerId = 1,
|
||||
@@ -50,12 +50,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Returns(_indexerDefinition);
|
||||
|
||||
}
|
||||
|
||||
private void GivenPublishDateFromToday(int days)
|
||||
{
|
||||
(_remoteAlbum.Release).PublishDate = DateTime.Today.AddDays(days);
|
||||
_remoteAlbum.Release.PublishDate = DateTime.Today.AddDays(days);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -108,7 +107,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
GivenPublishDateFromToday(days);
|
||||
|
||||
_indexerDefinition.Settings = new TorrentRssIndexerSettings{EarlyReleaseLimit = null};
|
||||
_indexerDefinition.Settings = new TorrentRssIndexerSettings { EarlyReleaseLimit = null };
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -5,21 +5,24 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class HistorySpecificationFixture : CoreTest<HistorySpecification>
|
||||
{
|
||||
private const int FIRST_ALBUM_ID = 1;
|
||||
private const int SECOND_ALBUM_ID = 2;
|
||||
|
||||
private HistorySpecification _upgradeHistory;
|
||||
|
||||
private RemoteAlbum _parseResultMulti;
|
||||
@@ -27,8 +30,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
private QualityModel _upgradableQuality;
|
||||
private QualityModel _notupgradableQuality;
|
||||
private Artist _fakeArtist;
|
||||
private const int FIRST_ALBUM_ID = 1;
|
||||
private const int SECOND_ALBUM_ID = 2;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -37,11 +38,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_upgradeHistory = Mocker.Resolve<HistorySpecification>();
|
||||
|
||||
var singleAlbumList = new List<Album> { new Album { Id = FIRST_ALBUM_ID } };
|
||||
var doubleAlbumList = new List<Album> {
|
||||
new Album {Id = FIRST_ALBUM_ID },
|
||||
new Album {Id = SECOND_ALBUM_ID },
|
||||
new Album {Id = 3 }
|
||||
};
|
||||
var doubleAlbumList = new List<Album>
|
||||
{
|
||||
new Album { Id = FIRST_ALBUM_ID },
|
||||
new Album { Id = SECOND_ALBUM_ID },
|
||||
new Album { Id = 3 }
|
||||
};
|
||||
|
||||
_fakeArtist = Builder<Artist>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile
|
||||
@@ -107,13 +109,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
// [Test]
|
||||
// public void should_return_true_if_latest_history_has_a_download_id_and_cdh_is_enabled()
|
||||
// {
|
||||
// GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
// _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void should_return_true_if_latest_history_has_a_download_id_and_cdh_is_enabled()
|
||||
// {
|
||||
// GivenMostRecentForEpisode(FIRST_EPISODE_ID, "test", _notupgradableQuality, DateTime.UtcNow, HistoryEventType.Grabbed);
|
||||
// _upgradeHistory.IsSatisfiedBy(_parseResultMulti, null).Accepted.Should().BeTrue();
|
||||
// }
|
||||
[Test]
|
||||
public void should_return_true_if_latest_history_item_is_older_than_twelve_hours()
|
||||
{
|
||||
|
||||
@@ -61,4 +61,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
@@ -34,7 +34,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_firstAlbum = new Album { Monitored = true };
|
||||
_secondAlbum = new Album { Monitored = true };
|
||||
|
||||
|
||||
var singleAlbumList = new List<Album> { _firstAlbum };
|
||||
var doubleAlbumList = new List<Album> { _firstAlbum, _secondAlbum };
|
||||
|
||||
@@ -122,7 +121,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public void should_return_false_if_album_is_not_monitored_and_monitoredEpisodesOnly_flag_is_true()
|
||||
{
|
||||
WithFirstAlbumUnmonitored();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new AlbumSearchCriteria{ MonitoredEpisodesOnly = true}).Accepted.Should().BeFalse();
|
||||
_monitoredAlbumSpecification.IsSatisfiedBy(_parseResultSingle, new AlbumSearchCriteria { MonitoredEpisodesOnly = true }).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NUnit.Framework;
|
||||
using FluentAssertions;
|
||||
using FizzWare.NBuilder;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -121,7 +121,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), age: 10);
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Album> { GivenAlbum(1) }, new QualityModel(Quality.MP3_256), age: 5);
|
||||
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
@@ -262,7 +261,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
torrentInfo1.Seeders = 10;
|
||||
torrentInfo1.Peers = 10;
|
||||
|
||||
|
||||
var torrentInfo2 = torrentInfo1.JsonClone();
|
||||
torrentInfo2.Peers = 100;
|
||||
|
||||
@@ -290,7 +288,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
torrentInfo1.Seeders = 0;
|
||||
torrentInfo1.Peers = 10;
|
||||
|
||||
|
||||
var torrentInfo2 = torrentInfo1.JsonClone();
|
||||
torrentInfo2.Seeders = 0;
|
||||
torrentInfo2.Peers = 100;
|
||||
@@ -398,7 +395,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
qualifiedReports.First().RemoteAlbum.ParsedAlbumInfo.Quality.Quality.Should().Be(Quality.MP3_320);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_prefer_higher_score_over_lower_score()
|
||||
{
|
||||
|
||||
@@ -4,10 +4,10 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_remoteAlbum = new RemoteAlbum();
|
||||
_remoteAlbum.Release = new ReleaseInfo();
|
||||
_remoteAlbum.Artist = new Artist();
|
||||
|
||||
|
||||
_delayProfile = new DelayProfile();
|
||||
|
||||
Mocker.GetMock<IDelayProfileService>()
|
||||
@@ -72,4 +72,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-12
@@ -3,10 +3,10 @@ using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
@@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
public class QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
|
||||
{
|
||||
private RemoteAlbum remoteAlbum;
|
||||
private RemoteAlbum _remoteAlbum;
|
||||
|
||||
public static object[] AllowedTestCases =
|
||||
{
|
||||
@@ -35,32 +35,34 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public void Setup()
|
||||
{
|
||||
var fakeArtist = Builder<Artist>.CreateNew()
|
||||
.With(c => c.QualityProfile = (LazyLoaded<QualityProfile>)new QualityProfile { Cutoff = Quality.MP3_320.Id })
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id })
|
||||
.Build();
|
||||
|
||||
remoteAlbum = new RemoteAlbum
|
||||
_remoteAlbum = new RemoteAlbum
|
||||
{
|
||||
Artist = fakeArtist,
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_192, new Revision(version: 2)) },
|
||||
};
|
||||
}
|
||||
|
||||
[Test, TestCaseSource(nameof(AllowedTestCases))]
|
||||
[Test]
|
||||
[TestCaseSource(nameof(AllowedTestCases))]
|
||||
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType;
|
||||
remoteAlbum.Artist.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_320);
|
||||
_remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType;
|
||||
_remoteAlbum.Artist.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_320);
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test, TestCaseSource(nameof(DeniedTestCases))]
|
||||
[Test]
|
||||
[TestCaseSource(nameof(DeniedTestCases))]
|
||||
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType;
|
||||
remoteAlbum.Artist.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_320);
|
||||
_remoteAlbum.ParsedAlbumInfo.Quality.Quality = qualityType;
|
||||
_remoteAlbum.Artist.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_192, Quality.MP3_256, Quality.MP3_320);
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Queue;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Indexers;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
_remoteAlbum.Release.Container = container;
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_no_container_specified()
|
||||
{
|
||||
@@ -60,6 +60,5 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
WithContainer("vob");
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -3,10 +3,10 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Releases;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -20,15 +20,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
_remoteAlbum = new RemoteAlbum
|
||||
{
|
||||
Artist = new Artist
|
||||
{
|
||||
Tags = new HashSet<int>()
|
||||
},
|
||||
Release = new ReleaseInfo
|
||||
{
|
||||
Title = "Dexter.S08E01.EDITED.WEBRip.x264-KYR"
|
||||
}
|
||||
};
|
||||
Artist = new Artist
|
||||
{
|
||||
Tags = new HashSet<int>()
|
||||
},
|
||||
Release = new ReleaseInfo
|
||||
{
|
||||
Title = "Dexter.S08E01.EDITED.WEBRip.x264-KYR"
|
||||
}
|
||||
};
|
||||
|
||||
Mocker.SetConstant<ITermMatcherService>(Mocker.Resolve<TermMatcherService>());
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Music;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -84,8 +84,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c => { c.ReleaseGroup = "Lidarr"; return c; }).ToList();
|
||||
_trackFiles.Select(c => { c.Quality = new QualityModel(Quality.MP3_256); return c; }).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.ReleaseGroup = "Lidarr";
|
||||
return c;
|
||||
}).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.Quality = new QualityModel(Quality.MP3_256);
|
||||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||
@@ -103,8 +111,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c => { c.ReleaseGroup = "Lidarr"; return c; }).ToList();
|
||||
_trackFiles.Select(c => { c.Quality = new QualityModel(Quality.FLAC); return c; }).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.ReleaseGroup = "Lidarr";
|
||||
return c;
|
||||
}).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.Quality = new QualityModel(Quality.FLAC);
|
||||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||
@@ -122,8 +138,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c => { c.ReleaseGroup = "Lidarr"; return c; }).ToList();
|
||||
_trackFiles.Select(c => { c.Quality = new QualityModel(Quality.FLAC); return c; }).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.ReleaseGroup = "Lidarr";
|
||||
return c;
|
||||
}).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.Quality = new QualityModel(Quality.FLAC);
|
||||
return c;
|
||||
}).ToList();
|
||||
|
||||
_trackFiles.First().ReleaseGroup = "NotLidarr";
|
||||
|
||||
@@ -138,14 +162,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_is_a_repack_for_different_group()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c => { c.ReleaseGroup = "NotLidarr"; return c; }).ToList();
|
||||
_trackFiles.Select(c => { c.Quality = new QualityModel(Quality.FLAC); return c; }).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.ReleaseGroup = "NotLidarr";
|
||||
return c;
|
||||
}).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.Quality = new QualityModel(Quality.FLAC);
|
||||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||
@@ -158,15 +189,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_release_group_for_existing_file_is_unknown()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c => { c.ReleaseGroup = ""; return c; }).ToList();
|
||||
_trackFiles.Select(c => { c.Quality = new QualityModel(Quality.FLAC); return c; }).ToList();
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.ReleaseGroup = "";
|
||||
return c;
|
||||
}).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.Quality = new QualityModel(Quality.FLAC);
|
||||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||
@@ -185,9 +222,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedAlbumInfo.ReleaseGroup = null;
|
||||
|
||||
_trackFiles.Select(c => { c.ReleaseGroup = "Lidarr"; return c; }).ToList();
|
||||
_trackFiles.Select(c => { c.Quality = new QualityModel(Quality.FLAC); return c; }).ToList();
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.ReleaseGroup = "Lidarr";
|
||||
return c;
|
||||
}).ToList();
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
c.Quality = new QualityModel(Quality.FLAC);
|
||||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||
|
||||
@@ -90,4 +90,4 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
@@ -12,12 +11,12 @@ using NzbDrone.Core.Download.Pending;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
@@ -34,7 +33,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
_profile = Builder<QualityProfile>.CreateNew()
|
||||
.Build();
|
||||
|
||||
|
||||
_delayProfile = Builder<DelayProfile>.CreateNew()
|
||||
.With(d => d.PreferredProtocol = DownloadProtocol.Usenet)
|
||||
.Build();
|
||||
@@ -77,9 +75,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(s => s.GetFilesByAlbum(It.IsAny<int>()))
|
||||
.Returns(new List<TrackFile> { new TrackFile {
|
||||
.Returns(new List<TrackFile>
|
||||
{
|
||||
new TrackFile
|
||||
{
|
||||
Quality = quality
|
||||
} });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void GivenUpgradeForExistingFile()
|
||||
|
||||
+23
-24
@@ -2,21 +2,19 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Common.Disk;
|
||||
using Moq;
|
||||
using NzbDrone.Test.Common;
|
||||
using System.IO;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
@@ -31,27 +29,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_firstFile =
|
||||
new TrackFile{
|
||||
Id = 1,
|
||||
Path = "/My.Artist.S01E01.mp3",
|
||||
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)),
|
||||
DateAdded = DateTime.Now,
|
||||
AlbumId = 1
|
||||
|
||||
};
|
||||
_secondFile =
|
||||
new TrackFile{
|
||||
Id = 2,
|
||||
Path = "/My.Artist.S01E02.mp3",
|
||||
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)),
|
||||
DateAdded = DateTime.Now,
|
||||
AlbumId = 2
|
||||
|
||||
};
|
||||
_firstFile =
|
||||
new TrackFile
|
||||
{
|
||||
Id = 1,
|
||||
Path = "/My.Artist.S01E01.mp3",
|
||||
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)),
|
||||
DateAdded = DateTime.Now,
|
||||
AlbumId = 1
|
||||
};
|
||||
_secondFile =
|
||||
new TrackFile
|
||||
{
|
||||
Id = 2,
|
||||
Path = "/My.Artist.S01E02.mp3",
|
||||
Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)),
|
||||
DateAdded = DateTime.Now,
|
||||
AlbumId = 2
|
||||
};
|
||||
|
||||
var singleAlbumList = new List<Album> { new Album { Id = 1 } };
|
||||
var doubleAlbumList = new List<Album> {
|
||||
var doubleAlbumList = new List<Album>
|
||||
{
|
||||
new Album { Id = 1 },
|
||||
new Album { Id = 2 }
|
||||
};
|
||||
|
||||
@@ -2,18 +2,17 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
@@ -35,9 +34,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
_firstFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
_secondFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 1)), DateAdded = DateTime.Now };
|
||||
|
||||
var singleAlbumList = new List<Album> { new Album {}, new Album {} };
|
||||
var doubleAlbumList = new List<Album> { new Album {}, new Album {}, new Album {} };
|
||||
|
||||
var singleAlbumList = new List<Album> { new Album { }, new Album { } };
|
||||
var doubleAlbumList = new List<Album> { new Album { }, new Album { }, new Album { } };
|
||||
|
||||
var fakeArtist = Builder<Artist>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.FLAC.Id })
|
||||
|
||||
@@ -3,8 +3,8 @@ using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
|
||||
+1
-3
@@ -6,9 +6,8 @@ using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.TorrentRss;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
@@ -44,7 +43,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Returns(_indexerDefinition);
|
||||
|
||||
}
|
||||
|
||||
private void GivenReleaseSeeders(int? seeders)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -22,8 +22,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
UpgradeAllowed = false
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.FLAC)
|
||||
).Should().BeFalse();
|
||||
new QualityModel(Quality.FLAC))
|
||||
.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -37,8 +37,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.FLAC)
|
||||
).Should().BeTrue();
|
||||
new QualityModel(Quality.FLAC))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -52,8 +52,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320)
|
||||
).Should().BeTrue();
|
||||
new QualityModel(Quality.MP3_320))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -67,8 +67,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
UpgradeAllowed = false
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_320)
|
||||
).Should().BeTrue();
|
||||
new QualityModel(Quality.MP3_320))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -82,8 +82,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_256)
|
||||
).Should().BeTrue();
|
||||
new QualityModel(Quality.MP3_256))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -96,9 +96,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = false
|
||||
},
|
||||
new List<QualityModel>{ new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_256)
|
||||
).Should().BeTrue();
|
||||
new List<QualityModel> { new QualityModel(Quality.MP3_320) },
|
||||
new QualityModel(Quality.MP3_256))
|
||||
.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
@@ -32,8 +31,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
_firstFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
_secondFile = new TrackFile { Quality = new QualityModel(Quality.FLAC, new Revision(version: 2)), DateAdded = DateTime.Now };
|
||||
|
||||
var singleAlbumList = new List<Album> { new Album {}};
|
||||
var doubleAlbumList = new List<Album> { new Album {}, new Album {}, new Album {} };
|
||||
var singleAlbumList = new List<Album> { new Album { } };
|
||||
var doubleAlbumList = new List<Album> { new Album { }, new Album { }, new Album { } };
|
||||
|
||||
var fakeArtist = Builder<Artist>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile
|
||||
@@ -65,7 +64,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
ParsedAlbumInfo = new ParsedAlbumInfo { Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)) },
|
||||
Albums = singleAlbumList
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private void WithFirstFileUpgradable()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -32,7 +32,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Returns(type);
|
||||
}
|
||||
|
||||
[Test, TestCaseSource(nameof(IsUpgradeTestCases))]
|
||||
[Test]
|
||||
[TestCaseSource(nameof(IsUpgradeTestCases))]
|
||||
public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected)
|
||||
{
|
||||
GivenAutoDownloadPropers(ProperDownloadTypes.PreferAndUpgrade);
|
||||
|
||||
Reference in New Issue
Block a user