Lidarr/NzbDrone.Core.Test/TvTests/EpisodeRepositoryTests/EpisodesWithoutFilesFixture.cs

116 lines
4.6 KiB
C#
Raw Normal View History

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>
{
private Series _monitoredSeries;
private Series _unmonitoredSeries;
private PagingSpec<Episode> _pagingSpec;
2013-04-20 17:28:17 +00:00
[SetUp]
public void Setup()
{
_monitoredSeries = Builder<Series>.CreateNew()
2013-04-20 17:28:17 +00:00
.With(s => s.Id = 0)
.With(s => s.Runtime = 30)
.With(s => s.Monitored = true)
2013-04-20 17:28:17 +00:00
.Build();
_unmonitoredSeries = Builder<Series>.CreateNew()
.With(s => s.Id = 0)
.With(s => s.Runtime = 30)
.With(s => s.Monitored = false)
.Build();
_monitoredSeries.Id = Db.Insert(_monitoredSeries).Id;
_unmonitoredSeries.Id = Db.Insert(_unmonitoredSeries).Id;
2013-04-20 17:28:17 +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)
.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)
.TheFirst(1)
.With(e => e.Monitored = false)
2013-04-20 17:28:17 +00:00
.TheLast(1)
.With(e => e.SeasonNumber = 0)
.Build();
var unmonitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3)
.All()
.With(e => e.Id = 0)
.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))
.With(e => e.Monitored = true)
.TheFirst(1)
.With(e => e.Monitored = false)
.TheLast(1)
.With(e => e.SeasonNumber = 0)
.Build();
Db.InsertMany(monitoredSeriesEpisodes);
Db.InsertMany(unmonitoredSeriesEpisodes);
2013-04-20 17:28:17 +00:00
}
[Test]
public void should_get_monitored_episodes()
2013-04-20 17:28:17 +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()
{
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
}
[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
}
}