2013-04-15 03:41:39 +02:00
|
|
|
|
using FluentAssertions;
|
2012-02-17 10:52:29 +01:00
|
|
|
|
using NUnit.Framework;
|
2013-02-24 07:48:52 +01:00
|
|
|
|
using NzbDrone.Core.Configuration;
|
2013-03-07 01:19:49 +01:00
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
2013-04-15 03:41:39 +02:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2012-02-17 10:52:29 +01:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
2013-02-19 03:19:38 +01:00
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
2012-02-17 10:52:29 +01:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-04-15 03:41:39 +02:00
|
|
|
|
|
|
|
|
|
public class RetentionSpecificationFixture : CoreTest<RetentionSpecification>
|
2012-02-17 10:52:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
private RemoteEpisode parseResult;
|
2012-02-17 10:52:29 +01:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
parseResult = new RemoteEpisode
|
2012-02-17 10:52:29 +01:00
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Report = new ReportInfo
|
|
|
|
|
{
|
|
|
|
|
Age = 100
|
|
|
|
|
}
|
2012-02-17 10:52:29 +01:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithUnlimitedRetention()
|
|
|
|
|
{
|
2013-02-24 20:39:31 +01:00
|
|
|
|
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(0);
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithLongRetention()
|
|
|
|
|
{
|
2013-02-24 20:39:31 +01:00
|
|
|
|
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(1000);
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithShortRetention()
|
|
|
|
|
{
|
2013-02-24 20:39:31 +01:00
|
|
|
|
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(10);
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithEqualRetention()
|
|
|
|
|
{
|
2013-02-24 20:39:31 +01:00
|
|
|
|
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(100);
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void unlimited_retention_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
WithUnlimitedRetention();
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void longer_retention_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
WithLongRetention();
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void equal_retention_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
WithEqualRetention();
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void shorter_retention_should_return_false()
|
|
|
|
|
{
|
|
|
|
|
WithShortRetention();
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Subject.IsSatisfiedBy(parseResult).Should().BeFalse();
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void zeroDay_report_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
WithUnlimitedRetention();
|
2013-04-15 03:41:39 +02:00
|
|
|
|
Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
|
2012-02-17 10:52:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|