2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-19 07:01:03 +01:00
|
|
|
|
|
2012-02-21 04:25:19 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-21 04:25:19 +01:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2013-03-28 07:49:38 +01:00
|
|
|
|
using NzbDrone.Test.Common;
|
2012-02-21 04:25:19 +01:00
|
|
|
|
|
2013-02-19 07:01:03 +01:00
|
|
|
|
namespace NzbDrone.Core.Test.TvTests
|
2012-02-21 04:25:19 +01:00
|
|
|
|
{
|
2013-03-28 07:49:38 +01:00
|
|
|
|
public class SeasonProviderTest : DbTest<SeasonRepository, Season>
|
2012-02-21 04:25:19 +01:00
|
|
|
|
{
|
2012-02-28 06:50:56 +01:00
|
|
|
|
[TestCase(true)]
|
|
|
|
|
[TestCase(false)]
|
2013-07-09 03:22:02 +02:00
|
|
|
|
public void Ismonitored_should_return_monitored_status_of_season(bool monitored)
|
2012-02-21 04:25:19 +01:00
|
|
|
|
{
|
|
|
|
|
var fakeSeason = Builder<Season>.CreateNew()
|
2013-07-09 03:22:02 +02:00
|
|
|
|
.With(s => s.Monitored = monitored)
|
2013-03-28 07:49:38 +01:00
|
|
|
|
.BuildNew<Season>();
|
2012-02-21 04:25:19 +01:00
|
|
|
|
|
|
|
|
|
Db.Insert(fakeSeason);
|
|
|
|
|
|
2013-07-09 03:22:02 +02:00
|
|
|
|
var result = Subject.IsMonitored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
2012-02-21 04:25:19 +01:00
|
|
|
|
|
2013-07-09 03:22:02 +02:00
|
|
|
|
result.Should().Be(monitored);
|
2012-02-21 04:25:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-07-09 03:22:02 +02:00
|
|
|
|
public void Monitored_should_return_true_if_not_in_db()
|
2012-02-21 07:50:38 +01:00
|
|
|
|
{
|
2013-07-09 03:22:02 +02:00
|
|
|
|
Subject.IsMonitored(10, 0).Should().BeTrue();
|
2012-02-21 07:50:38 +01:00
|
|
|
|
}
|
2012-02-28 06:50:56 +01:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetSeason_should_return_seasons_for_specified_series_only()
|
|
|
|
|
{
|
|
|
|
|
var seriesA = new[] { 1, 2, 3 };
|
|
|
|
|
var seriesB = new[] { 4, 5, 6 };
|
|
|
|
|
|
2013-03-28 07:49:38 +01:00
|
|
|
|
var seasonsA = seriesA.Select(c => new Season {SeasonNumber = c, SeriesId = 1}).ToList();
|
|
|
|
|
var seasonsB = seriesB.Select(c => new Season {SeasonNumber = c, SeriesId = 2}).ToList();
|
|
|
|
|
|
|
|
|
|
Subject.InsertMany(seasonsA);
|
|
|
|
|
Subject.InsertMany(seasonsB);
|
|
|
|
|
|
|
|
|
|
Subject.GetSeasonNumbers(1).Should().Equal(seriesA);
|
|
|
|
|
Subject.GetSeasonNumbers(2).Should().Equal(seriesB);
|
2012-02-28 06:50:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetSeason_should_return_emptylist_if_series_doesnt_exist()
|
|
|
|
|
{
|
2013-03-28 07:49:38 +01:00
|
|
|
|
Subject.GetSeasonNumbers(1).Should().BeEmpty();
|
2012-02-28 06:50:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-21 04:25:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|