mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Added episode status to back end, getting ready for backlog
This commit is contained in:
parent
3bfa1c52b7
commit
f33c2c4939
7 changed files with 177 additions and 31 deletions
119
NzbDrone.Core.Test/EpisodeStatusTest.cs
Normal file
119
NzbDrone.Core.Test/EpisodeStatusTest.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
// ReSharper disable RedundantUsingDirective
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
using System;
|
||||
using FizzWare.NBuilder;
|
||||
using MbUnit.Framework;
|
||||
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
|
||||
{
|
||||
[Test]
|
||||
[Row(1, false, false, EpisodeStatusType.NotAired)]
|
||||
[Row(-2, false, false, EpisodeStatusType.Missing)]
|
||||
[Row(1, true, false, EpisodeStatusType.Ready)]
|
||||
[Row(1, true, true, EpisodeStatusType.Ignored)]
|
||||
[Row(1, false, true, EpisodeStatusType.Ignored)]
|
||||
public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, EpisodeStatusType status)
|
||||
{
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Season = Builder<Season>.CreateNew()
|
||||
.With(s => s.Monitored = true).Build())
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[Row(1, false, false, EpisodeStatusType.NotAired)]
|
||||
[Row(-2, false, false, EpisodeStatusType.Missing)]
|
||||
[Row(1, true, false, EpisodeStatusType.Ready)]
|
||||
[Row(1, true, true, EpisodeStatusType.Ignored)]
|
||||
[Row(1, false, true, EpisodeStatusType.Ignored)]
|
||||
public void old_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
||||
EpisodeStatusType status)
|
||||
{
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Season = Builder<Season>.CreateNew()
|
||||
.With(s => s.Monitored = true).Build()).With(
|
||||
e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
||||
.With(e => e.Ignored = ignored)
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[Row(1, false, false, EpisodeStatusType.Downloading)]
|
||||
[Row(-2, false, false, EpisodeStatusType.Downloading)]
|
||||
[Row(1, true, false, EpisodeStatusType.Downloading)]
|
||||
[Row(1, true, true, EpisodeStatusType.Ignored)]
|
||||
[Row(1, false, true, EpisodeStatusType.Ignored)]
|
||||
public void recent_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
||||
EpisodeStatusType status)
|
||||
{
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Season = Builder<Season>.CreateNew()
|
||||
.With(s => s.Monitored = true).Build())
|
||||
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
||||
.With(e => e.Ignored = ignored)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = DateTime.Now.AddDays(-1))
|
||||
.Build();
|
||||
|
||||
if (hasEpisodes)
|
||||
{
|
||||
episode.EpisodeFileId = 12;
|
||||
}
|
||||
|
||||
Assert.AreEqual(status, episode.Status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Row(1, false, false, EpisodeStatusType.Ignored)]
|
||||
[Row(-2, false, false, EpisodeStatusType.Ignored)]
|
||||
[Row(1, true, false, EpisodeStatusType.Ignored)]
|
||||
[Row(1, true, true, EpisodeStatusType.Ignored)]
|
||||
[Row(1, false, true, EpisodeStatusType.Ignored)]
|
||||
public void skipped_season(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.Season = Builder<Season>.CreateNew()
|
||||
.With(s => s.Monitored == false).Build())
|
||||
.Build();
|
||||
|
||||
if (hasEpisodes)
|
||||
{
|
||||
episode.EpisodeFileId = 12;
|
||||
}
|
||||
|
||||
Assert.AreEqual(status, episode.Status);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue