2013-07-22 04:39:26 +00:00
|
|
|
|
using System;
|
|
|
|
|
using FizzWare.NBuilder;
|
2013-04-20 17:28:17 +00:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2013-05-02 05:50:34 +00:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-04-20 17:28:17 +00:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class EpisodesWithoutFilesFixture : DbTest<EpisodeRepository, Episode>
|
|
|
|
|
{
|
2013-07-22 04:39:26 +00:00
|
|
|
|
private Series _monitoredSeries;
|
|
|
|
|
private Series _unmonitoredSeries;
|
|
|
|
|
private PagingSpec<Episode> _pagingSpec;
|
2013-09-04 06:15:35 +00:00
|
|
|
|
|
2013-04-20 17:28:17 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-07-22 04:39:26 +00:00
|
|
|
|
_monitoredSeries = Builder<Series>.CreateNew()
|
2013-04-20 17:28:17 +00:00
|
|
|
|
.With(s => s.Id = 0)
|
2013-09-04 06:15:35 +00:00
|
|
|
|
.With(s => s.TvRageId = RandomNumber)
|
2013-04-20 17:28:17 +00:00
|
|
|
|
.With(s => s.Runtime = 30)
|
2013-07-15 21:53:35 +00:00
|
|
|
|
.With(s => s.Monitored = true)
|
2013-09-04 06:15:35 +00:00
|
|
|
|
.With(s => s.TitleSlug = "Title3")
|
2013-04-20 17:28:17 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2013-07-22 04:39:26 +00:00
|
|
|
|
_unmonitoredSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Id = 0)
|
2013-09-04 06:15:35 +00:00
|
|
|
|
.With(s => s.TvdbId = RandomNumber)
|
2013-07-22 04:39:26 +00:00
|
|
|
|
.With(s => s.Runtime = 30)
|
|
|
|
|
.With(s => s.Monitored = false)
|
2013-09-04 06:15:35 +00:00
|
|
|
|
.With(s => s.TitleSlug = "Title2")
|
2013-07-22 04:39:26 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
_monitoredSeries.Id = Db.Insert(_monitoredSeries).Id;
|
|
|
|
|
_unmonitoredSeries.Id = Db.Insert(_unmonitoredSeries).Id;
|
2013-04-20 17:28:17 +00:00
|
|
|
|
|
2013-07-22 04:39:26 +00:00
|
|
|
|
_pagingSpec = new PagingSpec<Episode>
|
|
|
|
|
{
|
|
|
|
|
Page = 1,
|
|
|
|
|
PageSize = 10,
|
|
|
|
|
SortKey = "AirDate",
|
|
|
|
|
SortDirection = SortDirection.Ascending
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var monitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3)
|
2013-04-20 17:28:17 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.Id = 0)
|
2013-09-04 06:15:35 +00:00
|
|
|
|
.With(e => e.TvDbEpisodeId = RandomNumber)
|
2013-07-22 04:39:26 +00:00
|
|
|
|
.With(e => e.SeriesId = _monitoredSeries.Id)
|
2013-04-20 17:28:17 +00:00
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
2013-07-24 05:40:29 +00:00
|
|
|
|
.With(e => e.AirDateUtc = DateTime.Now.AddDays(-5))
|
2013-07-15 22:38:41 +00:00
|
|
|
|
.With(e => e.Monitored = true)
|
2013-07-22 04:39:26 +00:00
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(e => e.Monitored = false)
|
2013-04-20 17:28:17 +00:00
|
|
|
|
.TheLast(1)
|
|
|
|
|
.With(e => e.SeasonNumber = 0)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-07-22 04:39:26 +00:00
|
|
|
|
var unmonitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.Id = 0)
|
2013-09-04 06:15:35 +00:00
|
|
|
|
.With(e => e.TvDbEpisodeId = RandomNumber)
|
2013-07-22 04:39:26 +00:00
|
|
|
|
.With(e => e.SeriesId = _unmonitoredSeries.Id)
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
2013-07-24 05:40:29 +00:00
|
|
|
|
.With(e => e.AirDateUtc = DateTime.Now.AddDays(-5))
|
2013-07-22 04:39:26 +00:00
|
|
|
|
.With(e => e.Monitored = true)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(e => e.Monitored = false)
|
|
|
|
|
.TheLast(1)
|
|
|
|
|
.With(e => e.SeasonNumber = 0)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-09-04 06:15:35 +00:00
|
|
|
|
|
2013-07-22 04:39:26 +00:00
|
|
|
|
Db.InsertMany(monitoredSeriesEpisodes);
|
|
|
|
|
Db.InsertMany(unmonitoredSeriesEpisodes);
|
2013-04-20 17:28:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-07-22 04:39:26 +00:00
|
|
|
|
public void should_get_monitored_episodes()
|
2013-04-20 17:28:17 +00:00
|
|
|
|
{
|
2013-07-22 04:39:26 +00:00
|
|
|
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
|
|
|
|
|
2013-05-02 05:50:34 +00:00
|
|
|
|
episodes.Records.Should().HaveCount(1);
|
2013-04-20 17:28:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-05-02 05:50:34 +00:00
|
|
|
|
[Ignore("Specials not implemented")]
|
2013-04-20 17:28:17 +00:00
|
|
|
|
public void should_get_episode_including_specials()
|
|
|
|
|
{
|
2013-07-22 04:39:26 +00:00
|
|
|
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, true);
|
|
|
|
|
|
2013-05-02 05:50:34 +00:00
|
|
|
|
episodes.Records.Should().HaveCount(2);
|
2013-04-20 17:28:17 +00:00
|
|
|
|
}
|
2013-07-22 04:39:26 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_include_unmonitored_episodes()
|
|
|
|
|
{
|
|
|
|
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
|
|
|
|
|
|
|
|
|
episodes.Records.Should().NotContain(e => e.Monitored == false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_contain_unmonitored_series()
|
|
|
|
|
{
|
|
|
|
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
|
|
|
|
|
|
|
|
|
episodes.Records.Should().NotContain(e => e.SeriesId == _unmonitoredSeries.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_have_count_of_one()
|
|
|
|
|
{
|
|
|
|
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
|
|
|
|
|
|
|
|
|
episodes.TotalRecords.Should().Be(1);
|
|
|
|
|
}
|
2013-04-20 17:28:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|