2011-09-14 04:37:22 +00:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
2011-10-20 23:42:17 +00:00
|
|
|
|
|
2012-02-07 05:08:07 +00:00
|
|
|
|
using System.Linq;
|
2011-09-14 04:37:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
2013-03-07 00:19:49 +00:00
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
2013-02-27 03:19:22 +00:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2011-09-14 04:37:22 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-02-19 02:19:38 +00:00
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2011-09-14 04:37:22 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
2013-02-19 02:19:38 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
2011-09-14 04:37:22 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-17 05:44:06 +00:00
|
|
|
|
public class AcceptableSizeSpecificationFixture : CoreTest
|
2011-09-14 04:37:22 +00:00
|
|
|
|
{
|
|
|
|
|
private EpisodeParseResult parseResultMulti;
|
|
|
|
|
private EpisodeParseResult parseResultSingle;
|
|
|
|
|
private Series series30minutes;
|
|
|
|
|
private Series series60minutes;
|
2013-02-27 03:19:22 +00:00
|
|
|
|
private QualitySize qualityType;
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
2011-10-24 05:54:09 +00:00
|
|
|
|
public void Setup()
|
2011-09-14 04:37:22 +00:00
|
|
|
|
{
|
|
|
|
|
parseResultMulti = new EpisodeParseResult
|
|
|
|
|
{
|
2012-01-20 05:37:08 +00:00
|
|
|
|
SeriesTitle = "Title",
|
2011-09-14 04:37:22 +00:00
|
|
|
|
Language = LanguageType.English,
|
2013-02-27 03:19:22 +00:00
|
|
|
|
Quality = new QualityModel(Quality.SDTV, true),
|
2011-09-14 04:37:22 +00:00
|
|
|
|
EpisodeNumbers = new List<int> { 3, 4 },
|
|
|
|
|
SeasonNumber = 12,
|
|
|
|
|
AirDate = DateTime.Now.AddDays(-12).Date
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parseResultSingle = new EpisodeParseResult
|
|
|
|
|
{
|
2012-01-20 05:37:08 +00:00
|
|
|
|
SeriesTitle = "Title",
|
2011-09-14 04:37:22 +00:00
|
|
|
|
Language = LanguageType.English,
|
2013-02-27 03:19:22 +00:00
|
|
|
|
Quality = new QualityModel(Quality.SDTV, true),
|
2011-09-14 04:37:22 +00:00
|
|
|
|
EpisodeNumbers = new List<int> { 3 },
|
|
|
|
|
SeasonNumber = 12,
|
|
|
|
|
AirDate = DateTime.Now.AddDays(-12).Date
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
series30minutes = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Monitored = true)
|
|
|
|
|
.With(d => d.CleanTitle = parseResultMulti.CleanTitle)
|
|
|
|
|
.With(c => c.Runtime = 30)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
series60minutes = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Monitored = true)
|
|
|
|
|
.With(d => d.CleanTitle = parseResultMulti.CleanTitle)
|
|
|
|
|
.With(c => c.Runtime = 60)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-02-27 03:19:22 +00:00
|
|
|
|
qualityType = Builder<QualitySize>.CreateNew()
|
2011-09-14 04:37:22 +00:00
|
|
|
|
.With(q => q.MinSize = 0)
|
2011-09-16 04:42:30 +00:00
|
|
|
|
.With(q => q.MaxSize = 10)
|
2013-02-27 03:19:22 +00:00
|
|
|
|
.With(q => q.QualityId = 1)
|
2011-09-14 04:37:22 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_not_first_or_last_30_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
parseResultSingle.Size = 184572800;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_not_first_or_last_60_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Size = 368572800;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_not_first_or_last_30_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
2011-10-25 05:15:20 +00:00
|
|
|
|
parseResultSingle.Size = 1.Gigabytes();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
2011-10-25 05:15:20 +00:00
|
|
|
|
parseResultSingle.Size = 1.Gigabytes();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultMulti.Series = series30minutes;
|
|
|
|
|
parseResultMulti.Size = 184572800;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultMulti.Series = series60minutes;
|
|
|
|
|
parseResultMulti.Size = 368572800;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultMulti.Series = series30minutes;
|
2011-10-25 05:15:20 +00:00
|
|
|
|
parseResultMulti.Size = 1.Gigabytes();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultMulti.Series = series60minutes;
|
2011-10-25 05:15:20 +00:00
|
|
|
|
parseResultMulti.Size = 10.Gigabytes();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_first_30_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
parseResultSingle.Size = 184572800;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_single_episode_first_60_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Size = 368572800;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_first_30_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
2011-10-25 05:15:20 +00:00
|
|
|
|
parseResultSingle.Size = 1.Gigabytes();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_false_single_episode_first_60_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
2011-10-25 05:15:20 +00:00
|
|
|
|
parseResultSingle.Size = 10.Gigabytes();
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-14 04:37:22 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
2011-09-16 04:42:30 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_unlimited_30_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-16 04:42:30 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series30minutes;
|
|
|
|
|
parseResultSingle.Size = 18457280000;
|
|
|
|
|
qualityType.MaxSize = 0;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-16 04:42:30 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-16 04:42:30 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-16 04:42:30 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_true_unlimited_60_minute()
|
|
|
|
|
{
|
2011-12-15 04:15:53 +00:00
|
|
|
|
WithStrictMocker();
|
2011-09-16 04:42:30 +00:00
|
|
|
|
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Size = 36857280000;
|
|
|
|
|
qualityType.MaxSize = 0;
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-09-16 04:42:30 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-09-16 04:42:30 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-09-16 04:42:30 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
2011-12-01 05:08:36 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsAcceptableSize_should_treat_daily_series_as_single_episode()
|
|
|
|
|
{
|
|
|
|
|
parseResultSingle.Series = series60minutes;
|
|
|
|
|
parseResultSingle.Size = 300.Megabytes();
|
|
|
|
|
parseResultSingle.AirDate = DateTime.Today;
|
|
|
|
|
parseResultSingle.EpisodeNumbers = null;
|
|
|
|
|
|
|
|
|
|
qualityType.MaxSize = (int)600.Megabytes();
|
|
|
|
|
|
2013-02-27 03:32:22 +00:00
|
|
|
|
Mocker.GetMock<IQualitySizeService>().Setup(s => s.Get(1)).Returns(qualityType);
|
2011-12-01 05:08:36 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>().Setup(
|
2011-12-01 05:08:36 +00:00
|
|
|
|
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2012-02-07 05:08:07 +00:00
|
|
|
|
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
|
2011-12-01 05:08:36 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
2013-01-09 08:15:06 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_if_RAWHD()
|
|
|
|
|
{
|
|
|
|
|
var parseResult = new EpisodeParseResult
|
|
|
|
|
{
|
2013-02-27 03:19:22 +00:00
|
|
|
|
Quality = new QualityModel(Quality.RAWHD, false)
|
2013-01-09 08:15:06 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
|
|
|
|
|
}
|
2011-09-14 04:37:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|