2011-10-24 05:54:09 +00:00
|
|
|
|
using System;
|
2011-05-22 16:53:06 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-23 06:56:17 +00:00
|
|
|
|
using FluentAssertions;
|
2011-06-02 21:06:46 +00:00
|
|
|
|
using NUnit.Framework;
|
2011-05-22 16:53:06 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
public class EpisodeStatusTest : TestBase
|
2011-08-22 06:32:38 +00:00
|
|
|
|
{
|
2011-06-02 21:06:46 +00:00
|
|
|
|
[TestCase(1, false, false, EpisodeStatusType.NotAired)]
|
|
|
|
|
[TestCase(-2, false, false, EpisodeStatusType.Missing)]
|
|
|
|
|
[TestCase(1, true, false, EpisodeStatusType.Ready)]
|
2011-05-22 16:53:06 +00:00
|
|
|
|
public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, EpisodeStatusType status)
|
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
|
|
|
|
.With(e => e.Ignored = ignored)
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
|
.With(e => e.GrabDate = null)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
|
|
|
|
episode.EpisodeFileId = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(status, episode.Status);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-04 01:56:53 +00:00
|
|
|
|
[TestCase(1, false, false, EpisodeStatusType.Missing)]
|
2011-06-02 21:06:46 +00:00
|
|
|
|
[TestCase(-2, false, false, EpisodeStatusType.Missing)]
|
|
|
|
|
[TestCase(1, true, false, EpisodeStatusType.Ready)]
|
2011-05-22 16:53:06 +00:00
|
|
|
|
public void old_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
|
|
|
|
EpisodeStatusType status)
|
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
2011-06-04 01:56:53 +00:00
|
|
|
|
.With(e => e.Ignored = ignored)
|
2011-05-22 16:53:06 +00:00
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
|
.With(e => e.GrabDate = DateTime.Now.AddDays(-1).AddHours(-1))
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
|
|
|
|
episode.EpisodeFileId = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(status, episode.Status);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-02 21:06:46 +00:00
|
|
|
|
[TestCase(1, false, false, EpisodeStatusType.Downloading)]
|
|
|
|
|
[TestCase(-2, false, false, EpisodeStatusType.Downloading)]
|
2011-07-10 20:07:42 +00:00
|
|
|
|
[TestCase(1, true, false, EpisodeStatusType.Ready)]
|
|
|
|
|
[TestCase(1, true, true, EpisodeStatusType.Ready)]
|
2011-06-02 21:06:46 +00:00
|
|
|
|
[TestCase(1, false, true, EpisodeStatusType.Downloading)]
|
2011-05-22 16:53:06 +00:00
|
|
|
|
public void recent_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
|
|
|
|
EpisodeStatusType status)
|
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
2011-06-04 01:56:53 +00:00
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
2011-05-22 16:53:06 +00:00
|
|
|
|
.With(e => e.Ignored = ignored)
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
2011-06-18 17:18:25 +00:00
|
|
|
|
.With(e => e.GrabDate = DateTime.Now.AddHours(22))
|
2011-05-22 16:53:06 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
|
|
|
|
episode.EpisodeFileId = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(status, episode.Status);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-04 01:56:53 +00:00
|
|
|
|
[TestCase(1, true, true, EpisodeStatusType.Ready)]
|
|
|
|
|
public void ignored_episode(int offsetDays, bool ignored, bool hasEpisodes, EpisodeStatusType status)
|
2011-05-22 16:53:06 +00:00
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
|
|
|
|
.With(e => e.Ignored = ignored)
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
2011-06-02 01:16:17 +00:00
|
|
|
|
.With(e => e.GrabDate = null)
|
2011-05-22 16:53:06 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
|
|
|
|
episode.EpisodeFileId = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(status, episode.Status);
|
|
|
|
|
}
|
2011-05-22 17:29:10 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void low_air_date()
|
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
2011-06-23 06:56:17 +00:00
|
|
|
|
.With(e => e.AirDate = DateTime.Now.AddDays(20))
|
2011-05-22 17:29:10 +00:00
|
|
|
|
.With(e => e.Ignored = false)
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
2011-06-02 01:16:17 +00:00
|
|
|
|
.With(e => e.GrabDate = null)
|
2011-05-22 17:29:10 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-06-02 01:16:17 +00:00
|
|
|
|
|
2011-06-23 06:56:17 +00:00
|
|
|
|
episode.Status.Should().Be(EpisodeStatusType.NotAired);
|
2011-05-22 17:29:10 +00:00
|
|
|
|
}
|
2011-10-12 03:44:19 +00:00
|
|
|
|
|
|
|
|
|
[TestCase(false, false, EpisodeStatusType.Failed, PostDownloadStatusType.Failed)]
|
|
|
|
|
[TestCase(false, false, EpisodeStatusType.Unpacking, PostDownloadStatusType.Unpacking)]
|
|
|
|
|
[TestCase(true, false, EpisodeStatusType.Ready, PostDownloadStatusType.Failed)]
|
|
|
|
|
[TestCase(true, true, EpisodeStatusType.Ready, PostDownloadStatusType.Unpacking)]
|
|
|
|
|
public void episode_downloaded_post_download_status_is_used(bool hasEpisodes, bool ignored,
|
|
|
|
|
EpisodeStatusType status, PostDownloadStatusType postDownloadStatus)
|
|
|
|
|
{
|
|
|
|
|
Episode episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.Ignored = ignored)
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
|
.With(e => e.GrabDate = DateTime.Now.AddHours(22))
|
|
|
|
|
.With(e => e.PostDownloadStatus = postDownloadStatus)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
if (hasEpisodes)
|
|
|
|
|
{
|
|
|
|
|
episode.EpisodeFileId = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(status, episode.Status);
|
|
|
|
|
}
|
2011-05-22 16:53:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|