You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixtu...

82 lines
2.1 KiB

using System;
using FluentAssertions;
13 years ago
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Parser.Model;
13 years ago
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
13 years ago
{
[TestFixture]
public class RetentionSpecificationFixture : CoreTest<RetentionSpecification>
13 years ago
{
private RemoteEpisode parseResult;
13 years ago
[SetUp]
public void Setup()
{
parseResult = new RemoteEpisode
13 years ago
{
Release = new ReleaseInfo()
13 years ago
};
}
private void WithRetention(int days)
13 years ago
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(days);
13 years ago
}
private void WithAge(int days)
13 years ago
{
parseResult.Release.PublishDate = DateTime.Now.AddDays(-days);
13 years ago
}
[Test]
public void should_return_true_when_retention_is_set_to_zero()
13 years ago
{
WithRetention(0);
WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
[Test]
public void should_return_true_when_release_if_younger_than_retention()
13 years ago
{
WithRetention(1000);
WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
[Test]
public void should_return_true_when_release_and_retention_are_the_same()
13 years ago
{
WithRetention(100);
WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
[Test]
public void should_return_false_when_old_than_retention()
13 years ago
{
WithRetention(10);
WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeFalse();
13 years ago
}
[Test]
public void should_return_true_if_release_came_out_today_and_retention_is_zero()
13 years ago
{
WithRetention(0);
WithAge(100);
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
}
}