mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Organized tests for DiskScan and PostDownload
Added tests for GetVideoFiles and ProcessVideoFile
This commit is contained in:
parent
3cdd479bb4
commit
cc6011ec87
16 changed files with 921 additions and 433 deletions
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ScanFixture : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void series_should_update_the_last_scan_date()
|
||||
{
|
||||
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.UpdateSeries(It.Is<Series>(s => s.LastDiskSync != null))).Verifiable();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.GetEpisodeBySeries(It.IsAny<long>()))
|
||||
.Returns(new List<Episode> { new Episode() });
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(c => c.FolderExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(c => c.GetSeriesFiles(It.IsAny<int>()))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().Scan(new Series());
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void series_should_log_warning_if_path_doesnt_exist_on_disk()
|
||||
{
|
||||
//Setup
|
||||
WithStrictMocker();
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Path = @"C:\Test\TV\SeriesName\")
|
||||
.Build();
|
||||
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(c => c.CleanUpDatabase());
|
||||
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(c => c.FolderExists(series.Path))
|
||||
.Returns(false);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<DiskScanProvider>().Scan(series, series.Path);
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue