|
|
@ -3,6 +3,8 @@ using System.Linq;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.SeriesStats;
|
|
|
|
using NzbDrone.Core.SeriesStats;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
@ -14,24 +16,29 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private Series _series;
|
|
|
|
private Series _series;
|
|
|
|
private Episode _episode;
|
|
|
|
private Episode _episode;
|
|
|
|
|
|
|
|
private EpisodeFile _episodeFile;
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_series = Builder<Series>.CreateNew()
|
|
|
|
_series = Builder<Series>.CreateNew()
|
|
|
|
.With(s => s.Id = 0)
|
|
|
|
|
|
|
|
.With(s => s.Runtime = 30)
|
|
|
|
.With(s => s.Runtime = 30)
|
|
|
|
.Build();
|
|
|
|
.BuildNew();
|
|
|
|
|
|
|
|
|
|
|
|
_series.Id = Db.Insert(_series).Id;
|
|
|
|
_series.Id = Db.Insert(_series).Id;
|
|
|
|
|
|
|
|
|
|
|
|
_episode = Builder<Episode>.CreateNew()
|
|
|
|
_episode = Builder<Episode>.CreateNew()
|
|
|
|
.With(e => e.Id = 0)
|
|
|
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
.With(e => e.Monitored = false)
|
|
|
|
.With(e => e.Monitored = false)
|
|
|
|
.With(e => e.SeriesId = _series.Id)
|
|
|
|
.With(e => e.SeriesId = _series.Id)
|
|
|
|
.With(e => e.AirDateUtc = DateTime.Today.AddDays(5))
|
|
|
|
.With(e => e.AirDateUtc = DateTime.Today.AddDays(5))
|
|
|
|
.Build();
|
|
|
|
.BuildNew();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_episodeFile = Builder<EpisodeFile>.CreateNew()
|
|
|
|
|
|
|
|
.With(e => e.SeriesId = _series.Id)
|
|
|
|
|
|
|
|
.With(e => e.Quality = new QualityModel(Quality.HDTV720p))
|
|
|
|
|
|
|
|
.BuildNew();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void GivenEpisodeWithFile()
|
|
|
|
private void GivenEpisodeWithFile()
|
|
|
@ -49,16 +56,21 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
_episode.Monitored = true;
|
|
|
|
_episode.Monitored = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void GivenFile()
|
|
|
|
private void GivenEpisode()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Db.Insert(_episode);
|
|
|
|
Db.Insert(_episode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void GivenEpisodeFile()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Db.Insert(_episodeFile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_get_stats_for_series()
|
|
|
|
public void should_get_stats_for_series()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GivenMonitoredEpisode();
|
|
|
|
GivenMonitoredEpisode();
|
|
|
|
GivenFile();
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
@ -71,7 +83,7 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
public void should_not_have_next_airing_for_episode_with_file()
|
|
|
|
public void should_not_have_next_airing_for_episode_with_file()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GivenEpisodeWithFile();
|
|
|
|
GivenEpisodeWithFile();
|
|
|
|
GivenFile();
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
@ -84,7 +96,7 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GivenEpisodeWithFile();
|
|
|
|
GivenEpisodeWithFile();
|
|
|
|
GivenOldEpisode();
|
|
|
|
GivenOldEpisode();
|
|
|
|
GivenFile();
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
@ -98,7 +110,7 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GivenMonitoredEpisode();
|
|
|
|
GivenMonitoredEpisode();
|
|
|
|
GivenOldEpisode();
|
|
|
|
GivenOldEpisode();
|
|
|
|
GivenFile();
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
@ -111,7 +123,7 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
public void should_not_have_previous_airing_for_old_episode_without_file_unmonitored()
|
|
|
|
public void should_not_have_previous_airing_for_old_episode_without_file_unmonitored()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GivenOldEpisode();
|
|
|
|
GivenOldEpisode();
|
|
|
|
GivenFile();
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
@ -123,7 +135,7 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_not_include_unmonitored_episode_in_episode_count()
|
|
|
|
public void should_not_include_unmonitored_episode_in_episode_count()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GivenFile();
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
@ -135,12 +147,36 @@ namespace NzbDrone.Core.Test.SeriesStatsTests
|
|
|
|
public void should_include_unmonitored_episode_with_file_in_episode_count()
|
|
|
|
public void should_include_unmonitored_episode_with_file_in_episode_count()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GivenEpisodeWithFile();
|
|
|
|
GivenEpisodeWithFile();
|
|
|
|
GivenFile();
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
|
stats.Should().HaveCount(1);
|
|
|
|
stats.Should().HaveCount(1);
|
|
|
|
stats.First().EpisodeCount.Should().Be(1);
|
|
|
|
stats.First().EpisodeCount.Should().Be(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_have_size_on_disk_of_zero_when_no_episode_file()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stats.Should().HaveCount(1);
|
|
|
|
|
|
|
|
stats.First().SizeOnDisk.Should().Be(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_have_size_on_disk_when_episode_file_exists()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
GivenEpisode();
|
|
|
|
|
|
|
|
GivenEpisodeFile();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var stats = Subject.SeriesStatistics();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stats.Should().HaveCount(1);
|
|
|
|
|
|
|
|
stats.First().SizeOnDisk.Should().Be(_episodeFile.Size);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|