|
|
|
@ -15,51 +15,62 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
|
|
|
|
|
public class AcceptableSizeSpecificationFixture : CoreTest<AcceptableSizeSpecification>
|
|
|
|
|
{
|
|
|
|
|
private RemoteEpisode parseResultMultiSet;
|
|
|
|
|
private RemoteEpisode parseResultMulti;
|
|
|
|
|
private RemoteEpisode parseResultSingle;
|
|
|
|
|
private Series series30minutes;
|
|
|
|
|
private Series series60minutes;
|
|
|
|
|
private Series series;
|
|
|
|
|
private QualityDefinition qualityType;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
series = Builder<Series>.CreateNew()
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
parseResultMultiSet = new RemoteEpisode
|
|
|
|
|
{
|
|
|
|
|
Series = series,
|
|
|
|
|
Release = new ReleaseInfo(),
|
|
|
|
|
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, true) },
|
|
|
|
|
Episodes = new List<Episode> { new Episode(), new Episode(), new Episode(), new Episode(), new Episode(), new Episode() }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parseResultMulti = new RemoteEpisode
|
|
|
|
|
{
|
|
|
|
|
Release = new ReleaseInfo(),
|
|
|
|
|
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, true) },
|
|
|
|
|
Episodes = new List<Episode> { new Episode(), new Episode() }
|
|
|
|
|
};
|
|
|
|
|
{
|
|
|
|
|
Series = series,
|
|
|
|
|
Release = new ReleaseInfo(),
|
|
|
|
|
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, true) },
|
|
|
|
|
Episodes = new List<Episode> { new Episode(), new Episode() }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parseResultSingle = new RemoteEpisode
|
|
|
|
|
{
|
|
|
|
|
Series = series,
|
|
|
|
|
Release = new ReleaseInfo(),
|
|
|
|
|
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.SDTV, true) },
|
|
|
|
|
Episodes = new List<Episode> { new Episode() }
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
series30minutes = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Runtime = 30)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
series60minutes = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Runtime = 60)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
qualityType = Builder<QualityDefinition>.CreateNew()
|
|
|
|
|
.With(q => q.MinSize = 0)
|
|
|
|
|
.With(q => q.MinSize = 2)
|
|
|
|
|
.With(q => q.MaxSize = 10)
|
|
|
|
|
.With(q => q.Quality = Quality.SDTV)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_not_first_or_last_30_minute()
|
|
|
|
|
[TestCase(30, 50, false)]
|
|
|
|
|
[TestCase(30, 250, true)]
|
|
|
|
|
[TestCase(30, 500, false)]
|
|
|
|
|
[TestCase(60, 100, false)]
|
|
|
|
|
[TestCase(60, 500, true)]
|
|
|
|
|
[TestCase(60, 1000, false)]
|
|
|
|
|
public void IsAcceptableSize_single_episode(int runtime, int sizeInMegaBytes, bool expectedResult)
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 184572800;
|
|
|
|
|
series.Runtime = runtime;
|
|
|
|
|
parseResultSingle.Series = series;
|
|
|
|
|
parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
@ -67,92 +78,43 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
result.Should().Be(expectedResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_not_first_or_last_60_minute()
|
|
|
|
|
[TestCase(30, 500, true)]
|
|
|
|
|
[TestCase(30, 1000, false)]
|
|
|
|
|
[TestCase(60, 1000, true)]
|
|
|
|
|
[TestCase(60, 2000, false)]
|
|
|
|
|
public void IsAcceptableSize_single_episode_first_or_last(int runtime, int sizeInMegaBytes, bool expectedResult)
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 368572800;
|
|
|
|
|
series.Runtime = runtime;
|
|
|
|
|
parseResultSingle.Series = series;
|
|
|
|
|
parseResultSingle.Release.Size = sizeInMegaBytes.Megabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_not_first_or_last_30_minute()
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 1.Gigabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute()
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 1.Gigabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute()
|
|
|
|
|
{
|
|
|
|
|
parseResultMulti.Series = series30minutes;
|
|
|
|
|
parseResultMulti.Release.Size = 184572800;
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
result.Should().Be(expectedResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute()
|
|
|
|
|
[TestCase(30, 50 * 2, false)]
|
|
|
|
|
[TestCase(30, 250 * 2, true)]
|
|
|
|
|
[TestCase(30, 500 * 2, false)]
|
|
|
|
|
[TestCase(60, 100 * 2, false)]
|
|
|
|
|
[TestCase(60, 500 * 2, true)]
|
|
|
|
|
[TestCase(60, 1000 * 2, false)]
|
|
|
|
|
public void IsAcceptableSize_multi_episode(int runtime, int sizeInMegaBytes, bool expectedResult)
|
|
|
|
|
{
|
|
|
|
|
parseResultMulti.Series = series60minutes;
|
|
|
|
|
parseResultMulti.Release.Size = 368572800;
|
|
|
|
|
series.Runtime = runtime;
|
|
|
|
|
parseResultMulti.Series = series;
|
|
|
|
|
parseResultMulti.Release.Size = sizeInMegaBytes.Megabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
@ -160,18 +122,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
result.Should().Be(expectedResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute()
|
|
|
|
|
[TestCase(30, 50 * 6, false)]
|
|
|
|
|
[TestCase(30, 250 * 6, true)]
|
|
|
|
|
[TestCase(30, 500 * 6, false)]
|
|
|
|
|
[TestCase(60, 100 * 6, false)]
|
|
|
|
|
[TestCase(60, 500 * 6, true)]
|
|
|
|
|
[TestCase(60, 1000 * 6, false)]
|
|
|
|
|
public void IsAcceptableSize_multiset_episode(int runtime, int sizeInMegaBytes, bool expectedResult)
|
|
|
|
|
{
|
|
|
|
|
parseResultMulti.Series = series30minutes;
|
|
|
|
|
parseResultMulti.Release.Size = 1.Gigabytes();
|
|
|
|
|
series.Runtime = runtime;
|
|
|
|
|
parseResultMultiSet.Series = series;
|
|
|
|
|
parseResultMultiSet.Release.Size = sizeInMegaBytes.Megabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
@ -179,116 +145,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultMultiSet, null);
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
result.Should().Be(expectedResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute()
|
|
|
|
|
public void IsAcceptableSize_return_true_if_unlimited_30_minute()
|
|
|
|
|
{
|
|
|
|
|
parseResultMulti.Series = series60minutes;
|
|
|
|
|
parseResultMulti.Release.Size = 10.Gigabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultMulti, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_first_30_minute()
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 184572800;
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_first_60_minute()
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 368572800;
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_first_30_minute()
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 1.Gigabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_first_60_minute()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Release.Size = 10.Gigabytes();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = Subject.IsSatisfiedBy(parseResultSingle, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_unlimited_30_minute()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
series.Runtime = 30;
|
|
|
|
|
parseResultSingle.Series = series;
|
|
|
|
|
parseResultSingle.Release.Size = 18457280000;
|
|
|
|
|
qualityType.MaxSize = 0;
|
|
|
|
|
|
|
|
|
@ -306,11 +172,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_unlimited_60_minute()
|
|
|
|
|
public void IsAcceptableSize_return_true_if_unlimited_60_minute()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
series.Runtime = 60;
|
|
|
|
|
parseResultSingle.Series = series;
|
|
|
|
|
parseResultSingle.Release.Size = 36857280000;
|
|
|
|
|
qualityType.MaxSize = 0;
|
|
|
|
|
|
|
|
|
@ -330,13 +195,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_should_treat_daily_series_as_single_episode()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
series.Runtime = 60;
|
|
|
|
|
parseResultSingle.Series = series;
|
|
|
|
|
parseResultSingle.Series.SeriesType = SeriesTypes.Daily;
|
|
|
|
|
|
|
|
|
|
parseResultSingle.Release.Size = 300.Megabytes();
|
|
|
|
|
|
|
|
|
|
qualityType.MaxSize = (int)600.Megabytes();
|
|
|
|
|
qualityType.MaxSize = 10;
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IQualityDefinitionService>().Setup(s => s.Get(Quality.SDTV)).Returns(qualityType);
|
|
|
|
|
|
|
|
|
@ -364,7 +229,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_always_return_false_if_unknow()
|
|
|
|
|
public void should_always_return_false_if_unknown()
|
|
|
|
|
{
|
|
|
|
|
var parseResult = new RemoteEpisode
|
|
|
|
|
{
|
|
|
|
|