2011-10-24 07:54:09 +02:00
|
|
|
|
using System;
|
2011-05-22 18:53:06 +02:00
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-23 08:56:17 +02:00
|
|
|
|
using FluentAssertions;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using NUnit.Framework;
|
2013-03-01 08:03:41 +01:00
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2011-05-22 18:53:06 +02:00
|
|
|
|
using NzbDrone.Core.Model;
|
2013-03-07 02:51:47 +01:00
|
|
|
|
|
2011-05-22 18:53:06 +02:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-17 06:44:06 +01:00
|
|
|
|
public class EpisodeStatusTest : CoreTest
|
2013-02-24 21:24:31 +01:00
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
[TestCase(1, false, false, EpisodeStatuses.NotAired)]
|
|
|
|
|
[TestCase(-2, false, false, EpisodeStatuses.Missing)]
|
|
|
|
|
[TestCase(0, false, false, EpisodeStatuses.AirsToday)]
|
|
|
|
|
[TestCase(1, true, false, EpisodeStatuses.Ready)]
|
|
|
|
|
public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, EpisodeStatuses status)
|
2011-05-22 18:53:06 +02:00
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
|
|
|
|
.With(e => e.Ignored = ignored)
|
|
|
|
|
.With(e => e.GrabDate = null)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
episode.EpisodeFile = new EpisodeFile();
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 21:24:31 +01:00
|
|
|
|
episode.Status.Should().Be(status);
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
[TestCase(1, false, false, EpisodeStatuses.Missing)]
|
|
|
|
|
[TestCase(-2, false, false, EpisodeStatuses.Missing)]
|
|
|
|
|
[TestCase(1, true, false, EpisodeStatuses.Ready)]
|
2011-05-22 18:53:06 +02:00
|
|
|
|
public void old_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
2013-04-15 03:41:39 +02:00
|
|
|
|
EpisodeStatuses status)
|
2011-05-22 18:53:06 +02:00
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
2011-06-04 03:56:53 +02:00
|
|
|
|
.With(e => e.Ignored = ignored)
|
2012-03-03 21:25:02 +01:00
|
|
|
|
.With(e => e.GrabDate = DateTime.Now.AddDays(-2).AddHours(-1))
|
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(-2))
|
2011-05-22 18:53:06 +02:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
episode.EpisodeFile = new EpisodeFile();
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-03 21:25:02 +01:00
|
|
|
|
episode.Status.Should().Be(status);
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
[TestCase(1, false, false, EpisodeStatuses.Downloading)]
|
|
|
|
|
[TestCase(-2, false, false, EpisodeStatuses.Downloading)]
|
|
|
|
|
[TestCase(1, true, false, EpisodeStatuses.Ready)]
|
|
|
|
|
[TestCase(1, true, true, EpisodeStatuses.Ready)]
|
|
|
|
|
[TestCase(1, false, true, EpisodeStatuses.Downloading)]
|
2011-05-22 18:53:06 +02:00
|
|
|
|
public void recent_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
2013-04-15 03:41:39 +02:00
|
|
|
|
EpisodeStatuses status)
|
2011-05-22 18:53:06 +02:00
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
2011-06-04 03:56:53 +02:00
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
2011-05-22 18:53:06 +02:00
|
|
|
|
.With(e => e.Ignored = ignored)
|
2011-06-18 19:18:25 +02:00
|
|
|
|
.With(e => e.GrabDate = DateTime.Now.AddHours(22))
|
2011-05-22 18:53:06 +02:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
episode.EpisodeFile = new EpisodeFile();
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 21:24:31 +01:00
|
|
|
|
episode.Status.Should().Be(status);
|
|
|
|
|
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
[TestCase(1, true, true, EpisodeStatuses.Ready)]
|
|
|
|
|
public void ignored_episode(int offsetDays, bool ignored, bool hasEpisodes, EpisodeStatuses status)
|
2011-05-22 18:53:06 +02:00
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
|
|
|
|
.With(e => e.Ignored = ignored)
|
2011-06-02 03:16:17 +02:00
|
|
|
|
.With(e => e.GrabDate = null)
|
2011-05-22 18:53:06 +02:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
episode.EpisodeFile = new EpisodeFile();
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 21:24:31 +01:00
|
|
|
|
episode.Status.Should().Be(status);
|
|
|
|
|
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
2011-05-22 19:29:10 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void low_air_date()
|
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
2011-06-23 08:56:17 +02:00
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(20))
|
2011-05-22 19:29:10 +02:00
|
|
|
|
.With(e => e.Ignored = false)
|
2011-06-02 03:16:17 +02:00
|
|
|
|
.With(e => e.GrabDate = null)
|
2011-05-22 19:29:10 +02:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-06-02 03:16:17 +02:00
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
episode.Status.Should().Be(EpisodeStatuses.NotAired);
|
2011-05-22 19:29:10 +02:00
|
|
|
|
}
|
2011-10-12 05:44:19 +02:00
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
[TestCase(false, false, EpisodeStatuses.Failed, PostDownloadStatusType.Failed)]
|
|
|
|
|
[TestCase(false, false, EpisodeStatuses.Unpacking, PostDownloadStatusType.Unpacking)]
|
|
|
|
|
[TestCase(true, false, EpisodeStatuses.Ready, PostDownloadStatusType.Failed)]
|
|
|
|
|
[TestCase(true, true, EpisodeStatuses.Ready, PostDownloadStatusType.Unpacking)]
|
2011-10-12 05:44:19 +02:00
|
|
|
|
public void episode_downloaded_post_download_status_is_used(bool hasEpisodes, bool ignored,
|
2013-04-15 03:41:39 +02:00
|
|
|
|
EpisodeStatuses status, PostDownloadStatusType postDownloadStatus)
|
2011-10-12 05:44:19 +02:00
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.Ignored = ignored)
|
|
|
|
|
.With(e => e.GrabDate = DateTime.Now.AddHours(22))
|
|
|
|
|
.With(e => e.PostDownloadStatus = postDownloadStatus)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
episode.EpisodeFile = new EpisodeFile();
|
2011-10-12 05:44:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 21:24:31 +01:00
|
|
|
|
episode.Status.Should().Be(status);
|
|
|
|
|
|
2011-10-12 05:44:19 +02:00
|
|
|
|
}
|
2011-05-22 18:53:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|