2013-03-28 23:07:09 +01:00
|
|
|
|
|
2012-02-17 10:52:29 +01:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
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;
|
2012-02-17 10:52:29 +01:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-02-19 03:19:38 +01:00
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2013-03-07 02:51:47 +01:00
|
|
|
|
|
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-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-17 06:44:06 +01:00
|
|
|
|
public class RetentionSpecificationFixture : CoreTest
|
2012-02-17 10:52:29 +01:00
|
|
|
|
{
|
|
|
|
|
private RetentionSpecification retentionSpecification;
|
|
|
|
|
|
2013-04-07 21:01:24 +02:00
|
|
|
|
private IndexerParseResult parseResult;
|
2012-02-17 10:52:29 +01:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
retentionSpecification = Mocker.Resolve<RetentionSpecification>();
|
|
|
|
|
|
2013-04-07 21:01:24 +02:00
|
|
|
|
parseResult = new IndexerParseResult
|
2012-02-17 10:52:29 +01:00
|
|
|
|
{
|
|
|
|
|
Age = 100
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
retentionSpecification.IsSatisfiedBy(parseResult).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void longer_retention_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
WithLongRetention();
|
|
|
|
|
retentionSpecification.IsSatisfiedBy(parseResult).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void equal_retention_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
WithEqualRetention();
|
|
|
|
|
retentionSpecification.IsSatisfiedBy(parseResult).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void shorter_retention_should_return_false()
|
|
|
|
|
{
|
|
|
|
|
WithShortRetention();
|
|
|
|
|
retentionSpecification.IsSatisfiedBy(parseResult).Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void zeroDay_report_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
WithUnlimitedRetention();
|
|
|
|
|
retentionSpecification.IsSatisfiedBy(parseResult).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|