mirror of https://github.com/Sonarr/Sonarr
Fixed UnitTests (set EpisodeFileId to zero where no episo.de file is expected back)
This commit is contained in:
parent
d416ec0147
commit
244e0f04f4
|
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.WhereAll().Have(e => e.SeriesId = 1).Build();
|
||||
.WhereAll().Have(e => e.SeriesId = 1).Have(e => e.EpisodeFileId = 0).Build();
|
||||
|
||||
|
||||
db.InsertMany(fakeEpisodes);
|
||||
|
@ -57,8 +57,8 @@ namespace NzbDrone.Core.Test
|
|||
var fakeEpisodes = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.EpisodeNumber = 1)
|
||||
.And(e => e.SeasonNumber = 2).Build();
|
||||
|
||||
.And(e => e.SeasonNumber = 2)
|
||||
.With(e => e.EpisodeFileId = 0).Build();
|
||||
|
||||
db.Insert(fakeEpisodes);
|
||||
|
||||
|
|
|
@ -19,43 +19,6 @@ namespace NzbDrone.Core.Test
|
|||
[TestFixture]
|
||||
public class SeriesProviderTest : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void Map_path_to_series()
|
||||
{
|
||||
//Arrange
|
||||
var fakeSeries = Builder<TvdbSeries>.CreateNew()
|
||||
.With(f => f.SeriesName = "The Simpsons")
|
||||
.Build();
|
||||
|
||||
var fakeSearch = Builder<TvdbSearchResult>.CreateNew()
|
||||
.With(s => s.Id = fakeSeries.Id)
|
||||
.With(s => s.SeriesName = fakeSeries.SeriesName)
|
||||
.Build();
|
||||
|
||||
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.GetMock<IDatabase>()
|
||||
.Setup(f => f.Exists<Series>(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
mocker.GetMock<TvDbProvider>()
|
||||
.Setup(f => f.GetSeries(It.IsAny<String>()))
|
||||
.Returns(fakeSearch);
|
||||
mocker.GetMock<TvDbProvider>()
|
||||
.Setup(f => f.GetSeries(fakeSeries.Id, false))
|
||||
.Returns(fakeSeries)
|
||||
.Verifiable();
|
||||
|
||||
//Act
|
||||
|
||||
var mappedSeries = mocker.Resolve<SeriesProvider>().MapPathToSeries(@"D:\TV Shows\The Simpsons");
|
||||
|
||||
//Assert
|
||||
mocker.GetMock<TvDbProvider>().VerifyAll();
|
||||
Assert.AreEqual(fakeSeries, mappedSeries);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void Add_new_series(bool useSeasonFolder)
|
||||
|
@ -129,6 +92,9 @@ namespace NzbDrone.Core.Test
|
|||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfileId = 1)
|
||||
.With(c => c.EpisodeCount = 0)
|
||||
.With(c => c.EpisodeFileCount = 0)
|
||||
.With(c => c.SeasonCount = 0)
|
||||
.Build();
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace NzbDrone.Core.Providers
|
|||
var episode = AttachSeries(_database.Fetch<Episode, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE EpisodeId = @0", id).Single());
|
||||
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
|
||||
|
|
Loading…
Reference in New Issue