sonarr-repo-only/NzbDrone.Core.Test/ProviderTests/DownloadProviderTests/ContainsRecentEpisode.cs

94 lines
2.9 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
{
[TestFixture]
public class ContainsRecentEpisode : CoreTest
{
private Episode _recentEpisode;
private Episode _oldEpisode;
[SetUp]
public void Setup()
{
_recentEpisode = Builder<Episode>
.CreateNew()
.With(e => e.AirDate = DateTime.Today)
.Build();
_oldEpisode = Builder<Episode>
.CreateNew()
.With(e => e.AirDate = DateTime.Today.AddDays(-365))
.Build();
}
[Test]
public void should_return_true_if_episode_aired_recently()
{
var epr = Builder<EpisodeParseResult>
.CreateNew()
.With(p => p.Episodes = new List<Episode>
{
_recentEpisode
})
.Build();
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeTrue();
}
[Test]
public void should_return_true_if_one_episode_aired_recently()
{
var epr = Builder<EpisodeParseResult>
.CreateNew()
.With(p => p.Episodes = new List<Episode>
{
_recentEpisode,
_oldEpisode
})
.Build();
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeTrue();
}
[Test]
public void should_return_false_if_episode_did_not_air_recently()
{
var epr = Builder<EpisodeParseResult>
.CreateNew()
.With(p => p.Episodes = new List<Episode>
{
_oldEpisode
})
.Build();
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeFalse();
}
[Test]
public void should_return_false_if_no_episode_aired_recently()
{
var epr = Builder<EpisodeParseResult>
.CreateNew()
.With(p => p.Episodes = new List<Episode>
{
_oldEpisode,
_oldEpisode
})
.Build();
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeFalse();
}
}
}