2012-10-17 07:56:07 +00:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-10-17 07:56:07 +00:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
2013-02-19 06:01:03 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
2012-10-17 07:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-02 20:54:03 +00:00
|
|
|
|
public class GetEpisodeBySceneNumberFixture : SqlCeTest
|
2012-10-17 07:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
private Series _series;
|
|
|
|
|
private Episode _episode;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
WithRealDb();
|
|
|
|
|
|
|
|
|
|
_series = Builder<Series>
|
|
|
|
|
.CreateNew()
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Db.Insert(_series);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void WithNullSceneNumbering()
|
|
|
|
|
{
|
|
|
|
|
_episode = Builder<Episode>
|
|
|
|
|
.CreateNew()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.With(e => e.SeriesId = _series.Id)
|
2012-10-17 07:56:07 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Db.Insert(_episode);
|
|
|
|
|
Db.Execute("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void WithSceneNumbering()
|
|
|
|
|
{
|
|
|
|
|
_episode = Builder<Episode>
|
|
|
|
|
.CreateNew()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.With(e => e.SeriesId = _series.Id)
|
2012-10-17 07:56:07 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Db.Insert(_episode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_null_if_no_episodes_in_db()
|
|
|
|
|
{
|
2013-02-26 03:58:57 +00:00
|
|
|
|
Mocker.Resolve<EpisodeService>().GetEpisodeBySceneNumbering(_series.Id, 1, 1).Should().BeNull();
|
2012-10-17 07:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_null_if_no_matching_episode_is_found()
|
|
|
|
|
{
|
|
|
|
|
WithNullSceneNumbering();
|
2013-02-26 03:58:57 +00:00
|
|
|
|
Mocker.Resolve<EpisodeService>().GetEpisodeBySceneNumbering(_series.Id, 1, 1).Should().BeNull();
|
2012-10-17 07:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_episode_if_matching_episode_is_found()
|
|
|
|
|
{
|
|
|
|
|
WithSceneNumbering();
|
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
var result = Mocker.Resolve<EpisodeService>()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.GetEpisodeBySceneNumbering(_series.Id, _episode.SceneSeasonNumber, _episode.SceneEpisodeNumber);
|
2012-10-17 07:56:07 +00:00
|
|
|
|
|
2013-02-26 03:58:57 +00:00
|
|
|
|
result.Id.Should().Be(_episode.Id);
|
2012-10-17 07:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|