diff --git a/NzbDrone.Core.Test/MediaFileProviderTests.cs b/NzbDrone.Core.Test/MediaFileProviderTests.cs index acfdc626a..124da51b6 100644 --- a/NzbDrone.Core.Test/MediaFileProviderTests.cs +++ b/NzbDrone.Core.Test/MediaFileProviderTests.cs @@ -53,7 +53,7 @@ public void import_new_file() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); var database = mocker.GetMock(MockBehavior.Strict); - database.Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(0).Verifiable(); + database.Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(false).Verifiable(); database.Setup(r => r.Insert(It.IsAny())).Returns(1).Verifiable(); @@ -97,7 +97,7 @@ public void import_new_daily_file() var mocker = new AutoMoqer(); var database = mocker.GetMock(MockBehavior.Strict); - database.Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(0).Verifiable(); + database.Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(false).Verifiable(); database.Setup(r => r.Insert(It.IsAny())).Returns(1).Verifiable(); mocker.GetMock() @@ -149,7 +149,7 @@ public void import_existing_season_file() var mocker = new AutoMoqer(); mocker.GetMock(MockBehavior.Strict) - .Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(1).Verifiable(); + .Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(true).Verifiable(); mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(size).Verifiable(); @@ -181,7 +181,7 @@ public void import_unparsable_file() var mocker = new AutoMoqer(); mocker.GetMock(MockBehavior.Strict) - .Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(0).Verifiable(); + .Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(false).Verifiable(); mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(size).Verifiable(); @@ -249,7 +249,7 @@ public void import_existing_file() //Mocks var mocker = new AutoMoqer(); mocker.GetMock(MockBehavior.Strict) - .Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(1).Verifiable(); + .Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(true).Verifiable(); mocker.GetMock(MockBehavior.Strict); mocker.GetMock() @@ -283,7 +283,7 @@ public void import_file_with_no_episode() //Mocks var mocker = new AutoMoqer(); mocker.GetMock(MockBehavior.Strict) - .Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(0).Verifiable(); + .Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(false).Verifiable(); mocker.GetMock(MockBehavior.Strict) .Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(null). @@ -405,7 +405,7 @@ public void import_new_download_success() configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false); var database = mocker.GetMock(MockBehavior.Strict); - database.Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(0).Verifiable(); + database.Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(false).Verifiable(); database.Setup(r => r.Insert(It.IsAny())).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(MockBehavior.Strict); - database.Setup(r => r.Single(It.IsAny(), It.IsAny())).Returns(0).Verifiable(); + database.Setup(r => r.Exists(It.IsAny(), It.IsAny())).Returns(false).Verifiable(); database.Setup(r => r.Insert(It.IsAny())).Returns(1); database.Setup(r => r.Delete(It.IsAny())).Returns(1); diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index a0b8bf0d0..b5b041fdf 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -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("SELECT COUNT (*) FROM EpisodeFiles WHERE Path =@0", Parser.NormalizePath(filePath)) == 0) + if (!_database.Exists("Path =@0", Parser.NormalizePath(filePath))) { var parseResult = Parser.ParseEpisodeInfo(filePath);