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...

85 lines
2.3 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
{
PublishDate = DateTime.Now.AddDays(-100)
}
13 years ago
};
}
private void WithUnlimitedRetention()
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(0);
13 years ago
}
private void WithLongRetention()
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(1000);
13 years ago
}
private void WithShortRetention()
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(10);
13 years ago
}
private void WithEqualRetention()
{
Mocker.GetMock<IConfigService>().SetupGet(c => c.Retention).Returns(100);
13 years ago
}
[Test]
public void unlimited_retention_should_return_true()
{
WithUnlimitedRetention();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
[Test]
public void longer_retention_should_return_true()
{
WithLongRetention();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
[Test]
public void equal_retention_should_return_true()
{
WithEqualRetention();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
[Test]
public void shorter_retention_should_return_false()
{
WithShortRetention();
Subject.IsSatisfiedBy(parseResult, null).Should().BeFalse();
13 years ago
}
[Test]
public void zeroDay_report_should_return_true()
{
WithUnlimitedRetention();
Subject.IsSatisfiedBy(parseResult, null).Should().BeTrue();
13 years ago
}
}
}