2012-02-17 09:52:29 +00:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2013-02-19 02:19:38 +00:00
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2012-02-17 09:52:29 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
2013-02-19 02:19:38 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
2012-02-17 09:52:29 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-17 05:44:06 +00:00
|
|
|
|
public class RetentionSpecificationFixture : CoreTest
|
2012-02-17 09:52:29 +00:00
|
|
|
|
{
|
|
|
|
|
private RetentionSpecification retentionSpecification;
|
|
|
|
|
|
|
|
|
|
private EpisodeParseResult parseResult;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
retentionSpecification = Mocker.Resolve<RetentionSpecification>();
|
|
|
|
|
|
|
|
|
|
parseResult = new EpisodeParseResult
|
|
|
|
|
{
|
|
|
|
|
Age = 100
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithUnlimitedRetention()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithLongRetention()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithShortRetention()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithEqualRetention()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|