mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
removed searchhistory storage.
This commit is contained in:
@@ -190,7 +190,6 @@
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\EmptyFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\DeleteFileFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\DeleteDirectoryFixture.cs" />
|
||||
<Compile Include="ProviderTests\SearchHistoryProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\PlexProviderTest.cs" />
|
||||
<Compile Include="TvTests\SeasonProviderTest.cs" />
|
||||
<Compile Include="DecisionEngineTests\RetentionSpecificationFixture.cs" />
|
||||
@@ -220,7 +219,6 @@
|
||||
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetXemSeriesIdsFixture.cs" />
|
||||
<Compile Include="Services\ParseErrorServiceFixture.cs" />
|
||||
<Compile Include="HelperTests\SortHelperFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />
|
||||
<Compile Include="DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\QualityTypeProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MisnamedProviderTest.cs" />
|
||||
|
||||
@@ -1,362 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Repository.Search;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SearchHistoryProviderTest : SqlCeTest
|
||||
{
|
||||
private SearchHistory _searchHistory;
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
.Build();
|
||||
|
||||
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.Quality = QualityTypes.SDTV)
|
||||
.Build().ToList();
|
||||
|
||||
_searchHistory = Builder<SearchHistory>.CreateNew()
|
||||
.With(h => h.EpisodeId = _episode.OID)
|
||||
.With(h => h.SeriesId - _series.OID)
|
||||
.With(h => h.SearchHistoryItems = items)
|
||||
.Build();
|
||||
}
|
||||
|
||||
private void WithUnsuccessfulSearch()
|
||||
{
|
||||
foreach(var item in _searchHistory.SearchHistoryItems)
|
||||
{
|
||||
item.Success = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void WithSuccessfulSearch()
|
||||
{
|
||||
foreach(var item in _searchHistory.SearchHistoryItems)
|
||||
{
|
||||
item.Success = false;
|
||||
}
|
||||
|
||||
var i = _searchHistory.SearchHistoryItems.Last();
|
||||
i.Success = true;
|
||||
i.SearchError = ReportRejectionType.None;
|
||||
}
|
||||
|
||||
private void WithExpiredHistory()
|
||||
{
|
||||
var history = Builder<SearchHistory>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(h => h.SearchTime = DateTime.Now.AddDays(-10))
|
||||
.Build();
|
||||
|
||||
foreach(var searchHistory in history)
|
||||
{
|
||||
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.Quality = QualityTypes.SDTV)
|
||||
.With(i => i.Id == searchHistory.Id)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(items);
|
||||
}
|
||||
|
||||
Db.InsertMany(history);
|
||||
}
|
||||
|
||||
private void WithValidHistory()
|
||||
{
|
||||
var history = Builder<SearchHistory>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(h => h.SearchTime = DateTime.Now)
|
||||
.Build();
|
||||
|
||||
foreach (var searchHistory in history)
|
||||
{
|
||||
var items = Builder<SearchHistoryItem>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.Quality = QualityTypes.SDTV)
|
||||
.With(i => i.Id == searchHistory.Id)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(items);
|
||||
}
|
||||
|
||||
Db.InsertMany(history);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_should_add_history_and_history_items()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
Db.Fetch<SearchHistory>().Should().HaveCount(1);
|
||||
Db.Fetch<SearchHistoryItem>().Should().HaveCount(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_should_add_return_id()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
result.Should().NotBe(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_should_delete_history_and_history_items()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var history = Db.Fetch<SearchHistory>();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Delete(history.First().Id);
|
||||
|
||||
Db.Fetch<SearchHistory>().Should().HaveCount(0);
|
||||
Db.Fetch<SearchHistoryItem>().Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllSearchHistory_should_return_all_items()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().AllSearchHistory();
|
||||
|
||||
result.Count.Should().Be(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllSearchHistory_should_have_series_title()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().AllSearchHistory();
|
||||
|
||||
result.Count.Should().Be(1);
|
||||
result.First().SeriesTitle.Should().Be(_series.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllSearchHistory_should_have_episode_information()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().AllSearchHistory();
|
||||
|
||||
result.Count.Should().Be(1);
|
||||
result.First().EpisodeTitle.Should().Be(_episode.Title);
|
||||
result.First().EpisodeNumber.Should().Be(_episode.EpisodeNumber);
|
||||
result.First().SeasonNumber.Should().Be(_episode.SeasonNumber);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllSearchHistory_should_have_totalItems_count()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().AllSearchHistory();
|
||||
|
||||
result.Count.Should().Be(1);
|
||||
result.First().TotalItems.Should().Be(_searchHistory.SearchHistoryItems.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllSearchHistory_should_have_successfulCount_equal_zero_when_all_failed()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
WithUnsuccessfulSearch();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().AllSearchHistory();
|
||||
|
||||
result.Count.Should().Be(1);
|
||||
result.First().SuccessfulCount.Should().Be(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllSearchHistory_should_have_successfulCount_equal_one_when_one_was_downloaded()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
WithSuccessfulSearch();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().AllSearchHistory();
|
||||
|
||||
result.Count.Should().Be(1);
|
||||
result.First().SuccessfulCount.Should().Be(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSearchHistory_should_return_searchHistory_with_items()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
WithSuccessfulSearch();
|
||||
var id = Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().GetSearchHistory(id);
|
||||
|
||||
result.SearchHistoryItems.Should().HaveCount(_searchHistory.SearchHistoryItems.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSearchHistory_should_have_episodeDetails()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
WithSuccessfulSearch();
|
||||
var id = Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().GetSearchHistory(id);
|
||||
|
||||
result.EpisodeNumber.Should().Be(_episode.EpisodeNumber);
|
||||
result.SeasonNumber.Should().Be(_episode.SeasonNumber);
|
||||
result.EpisodeTitle.Should().Be(_episode.Title);
|
||||
result.AirDate.Should().Be(_episode.AirDate.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSearchHistory_should_not_have_episode_info_if_it_was_a_full_season_search()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
|
||||
_searchHistory.EpisodeId = 0;
|
||||
var id = Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
|
||||
var result = Mocker.Resolve<SearchHistoryProvider>().GetSearchHistory(id);
|
||||
|
||||
result.EpisodeNumber.Should().Be(null);
|
||||
result.SeasonNumber.Should().Be(_searchHistory.SeasonNumber);
|
||||
result.EpisodeTitle.Should().Be(null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ForceDownload_should_download_report()
|
||||
{
|
||||
WithRealDb();
|
||||
Db.Insert(_series);
|
||||
Db.Insert(_episode);
|
||||
|
||||
var reportTitle = String.Format("{0} - S{1:00}E{2:00}", _series.Title, _episode.SeasonNumber, _episode.EpisodeNumber);
|
||||
_searchHistory.SearchHistoryItems.First().ReportTitle = reportTitle;
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Add(_searchHistory);
|
||||
var items = Db.Fetch<SearchHistoryItem>();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().ForceDownload(items.First().Id);
|
||||
|
||||
Mocker.GetMock<DownloadProvider>().Verify(v => v.DownloadReport(It.IsAny<EpisodeParseResult>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Cleanup_should_not_blowup_if_there_is_nothing_to_delete()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Cleanup();
|
||||
Db.Fetch<SearchHistory>().Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Cleanup_should_delete_searchHistory_older_than_1_week()
|
||||
{
|
||||
WithRealDb();
|
||||
WithExpiredHistory();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Cleanup();
|
||||
Db.Fetch<SearchHistory>().Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Cleanup_should_delete_searchHistoryItems_older_than_1_week()
|
||||
{
|
||||
WithRealDb();
|
||||
WithExpiredHistory();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Cleanup();
|
||||
Db.Fetch<SearchHistoryItem>().Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Cleanup_should_not_delete_searchHistory_younger_than_1_week()
|
||||
{
|
||||
WithRealDb();
|
||||
WithValidHistory();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Cleanup();
|
||||
Db.Fetch<SearchHistory>().Should().HaveCount(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Cleanup_should_not_delete_searchHistoryItems_younger_than_1_week()
|
||||
{
|
||||
WithRealDb();
|
||||
WithValidHistory();
|
||||
|
||||
Mocker.Resolve<SearchHistoryProvider>().Cleanup();
|
||||
Db.Fetch<SearchHistoryItem>().Should().HaveCount(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
||||
|
||||
public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider,
|
||||
IIndexerService indexerService, SceneMappingProvider sceneMappingProvider,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository)
|
||||
AllowedDownloadSpecification allowedDownloadSpecification, ISeriesRepository seriesRepository)
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
allowedDownloadSpecification)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
-226
@@ -1,226 +0,0 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_DeleteInvalidEpisodes : SqlCeTest
|
||||
{
|
||||
[Test]
|
||||
public void Delete_None_Valid_TvDbEpisodeId()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.OID = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.TvDbEpisodeId = tvDbSeries.First().Id)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_None_TvDbEpisodeId_is_zero()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.OID = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.TvDbEpisodeId = 0)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_None_TvDbEpisodeId_is_null()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.OID = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.TvDbEpisodeId = 0)
|
||||
.Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_TvDbId()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.OID = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.SeasonNumber = 20)
|
||||
.With(e => e.EpisodeNumber = 20)
|
||||
.With(e => e.TvDbEpisodeId = 300)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(0);
|
||||
}
|
||||
|
||||
//Other series, by season/episode + by tvdbid
|
||||
[Test]
|
||||
public void Delete_TvDbId_multiple_series()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.OID = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.SeasonNumber = 20)
|
||||
.With(e => e.EpisodeNumber = 20)
|
||||
.With(e => e.TvDbEpisodeId = 300)
|
||||
.Build();
|
||||
|
||||
//Other Series
|
||||
var otherFakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.OID = 12345)
|
||||
.Build();
|
||||
|
||||
var otherFakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = 12345)
|
||||
.With(e => e.SeasonNumber = 20)
|
||||
.With(e => e.EpisodeNumber = 20)
|
||||
.With(e => e.TvDbEpisodeId = 300)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
Db.Insert(otherFakeSeries);
|
||||
Db.Insert(otherFakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_do_anything_if_episode_list_is_empty()
|
||||
{
|
||||
WithStrictMocker();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, new List<TvdbEpisode>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user