2013-01-25 02:33:32 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
2013-02-24 22:18:48 +03:00
|
|
|
using NzbDrone.Core.Download;
|
2013-02-19 09:01:03 +03:00
|
|
|
using NzbDrone.Core.Tv;
|
2013-01-25 02:33:32 +03:00
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2013-02-17 08:44:06 +03:00
|
|
|
public class ContainsRecentEpisode : CoreTest
|
2013-01-25 02:33:32 +03:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|