mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
Added tests for GetEpisodeBySceneNumbering
This commit is contained in:
parent
9c6d78d479
commit
59bfa16462
@ -153,6 +153,7 @@
|
|||||||
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
||||||
<Compile Include="ProviderTests\DiskScanProviderTests\ScanFixture.cs" />
|
<Compile Include="ProviderTests\DiskScanProviderTests\ScanFixture.cs" />
|
||||||
<Compile Include="ProviderTests\DownloadClientTests\PneumaticProviderFixture.cs" />
|
<Compile Include="ProviderTests\DownloadClientTests\PneumaticProviderFixture.cs" />
|
||||||
|
<Compile Include="ProviderTests\EpisodeProviderTests\GetEpisodeBySceneNumberFixture.cs" />
|
||||||
<Compile Include="ProviderTests\Metadata\Xbmc_ForEpisodeFile_Fixture.cs" />
|
<Compile Include="ProviderTests\Metadata\Xbmc_ForEpisodeFile_Fixture.cs" />
|
||||||
<Compile Include="ProviderTests\Metadata\Xbmc_ForSeries_Fixture.cs" />
|
<Compile Include="ProviderTests\Metadata\Xbmc_ForSeries_Fixture.cs" />
|
||||||
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDropDirectoryFixture.cs" />
|
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDropDirectoryFixture.cs" />
|
||||||
@ -195,7 +196,7 @@
|
|||||||
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetXemSeriesIdsFixture.cs" />
|
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetXemSeriesIdsFixture.cs" />
|
||||||
<Compile Include="Services\ParseErrorServiceFixture.cs" />
|
<Compile Include="Services\ParseErrorServiceFixture.cs" />
|
||||||
<Compile Include="SortHelperTest.cs" />
|
<Compile Include="SortHelperTest.cs" />
|
||||||
<Compile Include="ProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />
|
<Compile Include="ProviderTests\EpisodeProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />
|
||||||
<Compile Include="ProviderTests\DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
|
<Compile Include="ProviderTests\DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
|
||||||
<Compile Include="ProviderTests\QualityTypeProviderTest.cs" />
|
<Compile Include="ProviderTests\QualityTypeProviderTest.cs" />
|
||||||
<Compile Include="ProviderTests\MisnamedProviderTest.cs" />
|
<Compile Include="ProviderTests\MisnamedProviderTest.cs" />
|
||||||
@ -205,7 +206,7 @@
|
|||||||
<Compile Include="CentralDispatchFixture.cs" />
|
<Compile Include="CentralDispatchFixture.cs" />
|
||||||
<Compile Include="ProviderTests\XbmcProviderTest.cs" />
|
<Compile Include="ProviderTests\XbmcProviderTest.cs" />
|
||||||
<Compile Include="ProviderTests\DiskScanProviderTests\MoveEpisodeFileFixture.cs" />
|
<Compile Include="ProviderTests\DiskScanProviderTests\MoveEpisodeFileFixture.cs" />
|
||||||
<Compile Include="ProviderTests\EpisodeProviderTest_GetEpisodesByParseResult.cs" />
|
<Compile Include="ProviderTests\EpisodeProviderTests\EpisodeProviderTest_GetEpisodesByParseResult.cs" />
|
||||||
<Compile Include="ProviderTests\DiskScanProviderTests\ImportFileFixture.cs" />
|
<Compile Include="ProviderTests\DiskScanProviderTests\ImportFileFixture.cs" />
|
||||||
<Compile Include="FluentTest.cs" />
|
<Compile Include="FluentTest.cs" />
|
||||||
<Compile Include="ProviderTests\LogProviderTests\LogProviderFixture.cs" />
|
<Compile Include="ProviderTests\LogProviderTests\LogProviderFixture.cs" />
|
||||||
@ -227,7 +228,7 @@
|
|||||||
<Compile Include="ProviderTests\HistoryProviderTest.cs" />
|
<Compile Include="ProviderTests\HistoryProviderTest.cs" />
|
||||||
<Compile Include="ProviderTests\MediaFileProviderTest.cs" />
|
<Compile Include="ProviderTests\MediaFileProviderTest.cs" />
|
||||||
<Compile Include="ProviderTests\ConfigProviderTests\ConfigProviderFixture.cs" />
|
<Compile Include="ProviderTests\ConfigProviderTests\ConfigProviderFixture.cs" />
|
||||||
<Compile Include="ProviderTests\EpisodeProviderTest.cs" />
|
<Compile Include="ProviderTests\EpisodeProviderTests\EpisodeProviderTest.cs" />
|
||||||
<Compile Include="Framework\TestDbHelper.cs" />
|
<Compile Include="Framework\TestDbHelper.cs" />
|
||||||
<Compile Include="ParserTest.cs" />
|
<Compile Include="ParserTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
@ -15,11 +13,10 @@ using NzbDrone.Core.Providers.Core;
|
|||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Repository.Quality;
|
using NzbDrone.Core.Repository.Quality;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
|
||||||
using PetaPoco;
|
using PetaPoco;
|
||||||
using TvdbLib.Data;
|
using TvdbLib.Data;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests
|
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
@ -2,17 +2,15 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
|
||||||
using TvdbLib.Data;
|
using TvdbLib.Data;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests
|
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
@ -5,17 +5,14 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
|
||||||
using PetaPoco;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests
|
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
@ -0,0 +1,77 @@
|
|||||||
|
// ReSharper disable RedundantUsingDirective
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Providers;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
public class GetEpisodeBySceneNumberFixture : CoreTest
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
.With(e => e.SeriesId = _series.SeriesId)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Db.Insert(_episode);
|
||||||
|
Db.Execute("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WithSceneNumbering()
|
||||||
|
{
|
||||||
|
_episode = Builder<Episode>
|
||||||
|
.CreateNew()
|
||||||
|
.With(e => e.SeriesId = _series.SeriesId)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Db.Insert(_episode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_null_if_no_episodes_in_db()
|
||||||
|
{
|
||||||
|
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_null_if_no_matching_episode_is_found()
|
||||||
|
{
|
||||||
|
WithNullSceneNumbering();
|
||||||
|
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_episode_if_matching_episode_is_found()
|
||||||
|
{
|
||||||
|
WithSceneNumbering();
|
||||||
|
|
||||||
|
var result = Mocker.Resolve<EpisodeProvider>()
|
||||||
|
.GetEpisodeBySceneNumbering(_series.SeriesId, _episode.SceneSeasonNumber, _episode.SceneEpisodeNumber);
|
||||||
|
|
||||||
|
result.EpisodeId.Should().Be(_episode.EpisodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -191,7 +191,7 @@ namespace NzbDrone.Core.Providers
|
|||||||
Episode episodeInfo;
|
Episode episodeInfo;
|
||||||
|
|
||||||
if (parseResult.SceneSource && parseResult.Series.UseSceneNumbering)
|
if (parseResult.SceneSource && parseResult.Series.UseSceneNumbering)
|
||||||
episodeInfo = GetEpisodeFromSceneNumbering(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
episodeInfo = GetEpisodeBySceneNumbering(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ namespace NzbDrone.Core.Providers
|
|||||||
_database.UpdateMany(episodes);
|
_database.UpdateMany(episodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Episode GetEpisodeFromSceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
|
public virtual Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
|
||||||
{
|
{
|
||||||
var episode = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
var episode = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||||
|
Loading…
Reference in New Issue
Block a user