mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-27 10:07:10 +00:00
Cleaned up units tests.
This commit is contained in:
parent
b36dc4ab86
commit
5522466497
1 changed files with 47 additions and 34 deletions
|
@ -50,37 +50,37 @@ private void BuildIndexers()
|
|||
{
|
||||
_episodeIndexer1 = new Mock<IndexerBase>();
|
||||
_episodeIndexer1.Setup(c => c.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(_parseResults).Verifiable();
|
||||
.Returns(_parseResults);
|
||||
|
||||
_episodeIndexer2 = new Mock<IndexerBase>();
|
||||
_episodeIndexer2.Setup(c => c.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(_parseResults).Verifiable();
|
||||
.Returns(_parseResults);
|
||||
|
||||
_seasonIndexer1 = new Mock<IndexerBase>();
|
||||
_seasonIndexer1.Setup(c => c.FetchSeason(It.IsAny<string>(), It.IsAny<int>()))
|
||||
.Returns(_parseResults).Verifiable();
|
||||
.Returns(_parseResults);
|
||||
|
||||
_seasonIndexer2 = new Mock<IndexerBase>();
|
||||
_seasonIndexer2.Setup(c => c.FetchSeason(It.IsAny<string>(), It.IsAny<int>()))
|
||||
.Returns(_parseResults).Verifiable();
|
||||
.Returns(_parseResults);
|
||||
|
||||
_partialSeasonIndexer1 = new Mock<IndexerBase>();
|
||||
_partialSeasonIndexer1.Setup(c => c.FetchPartialSeason(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(_parseResults).Verifiable();
|
||||
.Returns(_parseResults);
|
||||
|
||||
_partialSeasonIndexer2 = new Mock<IndexerBase>();
|
||||
_partialSeasonIndexer2.Setup(c => c.FetchPartialSeason(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(_parseResults).Verifiable();
|
||||
.Returns(_parseResults);
|
||||
|
||||
_brokenIndexer = new Mock<IndexerBase>();
|
||||
_brokenIndexer.Setup(c => c.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Throws(new Exception()).Verifiable();
|
||||
.Throws(new Exception());
|
||||
|
||||
List<EpisodeParseResult> nullResult = null;
|
||||
|
||||
_nullIndexer = new Mock<IndexerBase>();
|
||||
_nullIndexer.Setup(c => c.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(nullResult).Verifiable();
|
||||
.Returns(nullResult);
|
||||
}
|
||||
|
||||
private void WithEpisodeIndexers()
|
||||
|
@ -151,6 +151,39 @@ private void WithNullEpisodes()
|
|||
_episodes = null;
|
||||
}
|
||||
|
||||
private void VerifyFetchEpisode(Times times)
|
||||
{
|
||||
_episodeIndexer1.Verify(v => v.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, times);
|
||||
|
||||
_episodeIndexer2.Verify(v => v.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, times);
|
||||
}
|
||||
|
||||
private void VerifyFetchEpisodeBrokenIndexer(Times times)
|
||||
{
|
||||
_brokenIndexer.Verify(v => v.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, times);
|
||||
}
|
||||
|
||||
private void VerifyFetchPartialSeason(Times times)
|
||||
{
|
||||
_partialSeasonIndexer1.Verify(v => v.FetchPartialSeason(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, times);
|
||||
|
||||
_partialSeasonIndexer2.Verify(v => v.FetchPartialSeason(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, times);
|
||||
}
|
||||
|
||||
private void VerifyFetchSeason(Times times)
|
||||
{
|
||||
_seasonIndexer1.Verify(v => v.FetchSeason(It.IsAny<string>(), It.IsAny<int>())
|
||||
, times);
|
||||
|
||||
_seasonIndexer1.Verify(v => v.FetchSeason(It.IsAny<string>(), It.IsAny<int>())
|
||||
, times);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PerformSearch_should_search_all_enabled_providers()
|
||||
{
|
||||
|
@ -162,9 +195,8 @@ public void PerformSearch_should_search_all_enabled_providers()
|
|||
var result = Mocker.Resolve<SearchProvider>().PerformSearch(new ProgressNotification("Test"), _series, 1, _episodes);
|
||||
|
||||
//Assert
|
||||
VerifyFetchEpisode(Times.Once());
|
||||
result.Should().HaveCount(20);
|
||||
_episodeIndexer1.VerifyAll();
|
||||
_episodeIndexer1.VerifyAll();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -179,10 +211,6 @@ public void PerformSearch_should_look_for_scene_name_to_search()
|
|||
var result = Mocker.Resolve<SearchProvider>().PerformSearch(new ProgressNotification("Test"), _series, 1, _episodes);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(20);
|
||||
_episodeIndexer1.VerifyAll();
|
||||
_episodeIndexer2.VerifyAll();
|
||||
|
||||
Mocker.GetMock<SceneMappingProvider>().Verify(c => c.GetSceneName(It.IsAny<int>()),
|
||||
Times.Once());
|
||||
}
|
||||
|
@ -200,9 +228,8 @@ public void PerformSearch_broken_indexer_should_not_break_job()
|
|||
//Assert
|
||||
result.Should().HaveCount(20);
|
||||
ExceptionVerification.ExcpectedErrors(1);
|
||||
_episodeIndexer1.VerifyAll();
|
||||
_episodeIndexer2.VerifyAll();
|
||||
_brokenIndexer.VerifyAll();
|
||||
VerifyFetchEpisode(Times.Once());
|
||||
VerifyFetchEpisodeBrokenIndexer(Times.Once());
|
||||
|
||||
Mocker.GetMock<SceneMappingProvider>().Verify(c => c.GetSceneName(It.IsAny<int>()),
|
||||
Times.Once());
|
||||
|
@ -221,11 +248,7 @@ public void PerformSearch_for_episode_should_call_FetchEpisode()
|
|||
//Assert
|
||||
result.Should().HaveCount(20);
|
||||
|
||||
_episodeIndexer1.Verify(v => v.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, Times.Once());
|
||||
|
||||
_episodeIndexer2.Verify(v => v.FetchEpisode(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, Times.Once());
|
||||
VerifyFetchEpisode(Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -240,12 +263,7 @@ public void PerformSearch_for_partial_season_should_call_FetchPartialSeason()
|
|||
|
||||
//Assert
|
||||
result.Should().HaveCount(80);
|
||||
|
||||
_partialSeasonIndexer1.Verify(v => v.FetchPartialSeason(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, Times.Exactly(4));
|
||||
|
||||
_partialSeasonIndexer2.Verify(v => v.FetchPartialSeason(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())
|
||||
, Times.Exactly(4));
|
||||
VerifyFetchPartialSeason(Times.Exactly(4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -260,12 +278,7 @@ public void PerformSearch_for_season_should_call_FetchSeason()
|
|||
|
||||
//Assert
|
||||
result.Should().HaveCount(20);
|
||||
|
||||
_seasonIndexer1.Verify(v => v.FetchSeason(It.IsAny<string>(), It.IsAny<int>())
|
||||
, Times.Once());
|
||||
|
||||
_seasonIndexer1.Verify(v => v.FetchSeason(It.IsAny<string>(), It.IsAny<int>())
|
||||
, Times.Once());
|
||||
VerifyFetchSeason(Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
Loading…
Reference in a new issue