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/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixtu...

94 lines
2.6 KiB

13 years ago
// 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.Configuration;
using NzbDrone.Core.DecisionEngine.Specifications;
13 years ago
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.DecisionEngine;
13 years ago
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
13 years ago
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class RetentionSpecificationFixture : CoreTest
13 years ago
{
private RetentionSpecification retentionSpecification;
private EpisodeParseResult parseResult;
[SetUp]
public void Setup()
{
retentionSpecification = Mocker.Resolve<RetentionSpecification>();
parseResult = new EpisodeParseResult
{
Age = 100
};
}
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();
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();
}
}
}