mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-12 11:15:43 +02:00
Using new PetaPoco Exists method in MediaFileProvider.
This commit is contained in:
parent
114f0675e0
commit
63023d447d
@ -53,7 +53,7 @@ public void import_new_file()
|
||||
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
|
||||
|
||||
var database = mocker.GetMock<IDatabase>(MockBehavior.Strict);
|
||||
database.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(0).Verifiable();
|
||||
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1).Verifiable();
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ public void import_new_daily_file()
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
var database = mocker.GetMock<IDatabase>(MockBehavior.Strict);
|
||||
database.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(0).Verifiable();
|
||||
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1).Verifiable();
|
||||
|
||||
mocker.GetMock<EpisodeProvider>()
|
||||
@ -149,7 +149,7 @@ public void import_existing_season_file()
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.GetMock<IDatabase>(MockBehavior.Strict)
|
||||
.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(1).Verifiable();
|
||||
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(true).Verifiable();
|
||||
|
||||
mocker.GetMock<DiskProvider>()
|
||||
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
|
||||
@ -181,7 +181,7 @@ public void import_unparsable_file()
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.GetMock<IDatabase>(MockBehavior.Strict)
|
||||
.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(0).Verifiable();
|
||||
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||
|
||||
mocker.GetMock<DiskProvider>()
|
||||
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
|
||||
@ -249,7 +249,7 @@ public void import_existing_file()
|
||||
//Mocks
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.GetMock<IDatabase>(MockBehavior.Strict)
|
||||
.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(1).Verifiable();
|
||||
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(true).Verifiable();
|
||||
|
||||
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict);
|
||||
mocker.GetMock<DiskProvider>()
|
||||
@ -283,7 +283,7 @@ public void import_file_with_no_episode()
|
||||
//Mocks
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.GetMock<IDatabase>(MockBehavior.Strict)
|
||||
.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(0).Verifiable();
|
||||
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||
|
||||
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict)
|
||||
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).
|
||||
@ -405,7 +405,7 @@ public void import_new_download_success()
|
||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||
|
||||
var database = mocker.GetMock<IDatabase>(MockBehavior.Strict);
|
||||
database.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(0).Verifiable();
|
||||
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1).Verifiable();
|
||||
|
||||
//Act
|
||||
@ -467,7 +467,7 @@ public void import_new_download_success_delete_equal_quality()
|
||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||
|
||||
var database = mocker.GetMock<IDatabase>(MockBehavior.Strict);
|
||||
database.Setup(r => r.Single<int>(It.IsAny<string>(), It.IsAny<object>())).Returns(0).Verifiable();
|
||||
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1);
|
||||
database.Setup(r => r.Delete<EpisodeFile>(It.IsAny<int>())).Returns(1);
|
||||
|
||||
|
@ -75,7 +75,7 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
}
|
||||
|
||||
//Check to see if file already exists in the database
|
||||
if (_database.Single<int>("SELECT COUNT (*) FROM EpisodeFiles WHERE Path =@0", Parser.NormalizePath(filePath)) == 0)
|
||||
if (!_database.Exists<EpisodeFile>("Path =@0", Parser.NormalizePath(filePath)))
|
||||
{
|
||||
var parseResult = Parser.ParseEpisodeInfo(filePath);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user