1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

test clean up.

This commit is contained in:
Keivan Beigi 2013-03-28 15:07:09 -07:00
parent 7eb0d62c53
commit a221994cd7
90 changed files with 779 additions and 804 deletions

View File

@ -41,10 +41,10 @@
// .Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
// .Returns(dummy);
// //act
//
// Mocker.Resolve<IISProvider>().StartServer();
// //assert
//
// Mocker.Resolve<IISProvider>().IISProcessId.Should().Be(dummy.Id);
// }

View File

@ -10,7 +10,7 @@
namespace NzbDrone.Common.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class ConfigFileProviderTest : TestBase
{
[SetUp]

View File

@ -1,6 +1,4 @@
// ReSharper disable InconsistentNaming
using System;
using System;
using System.IO;
using System.Linq;
using FluentAssertions;
@ -84,11 +82,11 @@ public void moveFile_should_not_move_overwrite_itself()
[Test]
public void CopyFolder_should_copy_folder()
{
//Act
var diskProvider = new DiskProvider();
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
//Assert
VerifyCopy();
}
@ -96,7 +94,7 @@ public void CopyFolder_should_copy_folder()
[Test]
public void CopyFolder_should_overright_existing_folder()
{
//Act
var diskProvider = new DiskProvider();
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
@ -107,7 +105,7 @@ public void CopyFolder_should_overright_existing_folder()
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
//Assert
VerifyCopy();
}
@ -120,10 +118,10 @@ public void MoveFolder_should_overright_existing_folder()
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderMove.FullName);
VerifyCopy();
//Act
diskProvider.MoveDirectory(BinFolderCopy.FullName, BinFolderMove.FullName);
//Assert
VerifyMove();
}

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming

using System;
using System.IO;

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming

using System;
using System.ComponentModel;
@ -70,7 +70,7 @@ public void Should_be_able_to_start_process()
{
var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
//Act/Assert
_processProvider.GetProcessByName(DummyApp.DUMMY_PROCCESS_NAME).Should()
.BeEmpty("Dummy process is already running");
_processProvider.Start(startInfo).Should().NotBeNull();

View File

@ -7,7 +7,7 @@
namespace NzbDrone.Common.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class ReportingService_ReportParseError_Fixture : TestBase
{
[SetUp]

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming

using System.ServiceProcess;
using FluentAssertions;
@ -43,7 +43,7 @@ public void TearDown()
[Test]
public void Exists_should_find_existing_service()
{
//Act
var exists = serviceProvider.ServiceExist(ALWAYS_INSTALLED_SERVICE);
exists.Should().BeTrue();
@ -52,7 +52,7 @@ public void Exists_should_find_existing_service()
[Test]
public void Exists_should_not_find_random_service()
{
//Act
var exists = serviceProvider.ServiceExist("random_service_name");
exists.Should().BeFalse();
@ -62,7 +62,7 @@ public void Exists_should_not_find_random_service()
[Test]
public void Service_should_be_installed_and_then_uninstalled()
{
//Act
serviceProvider.ServiceExist(TEMP_SERVICE_NAME).Should().BeFalse("Service already installed");
serviceProvider.Install(TEMP_SERVICE_NAME);
serviceProvider.ServiceExist(TEMP_SERVICE_NAME).Should().BeTrue();
@ -76,7 +76,7 @@ public void Service_should_be_installed_and_then_uninstalled()
[Explicit]
public void UnInstallService()
{
//Act
serviceProvider.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME);
serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME).Should().BeFalse();
}
@ -105,10 +105,10 @@ public void Should_log_warn_if_on_stop_if_service_is_already_stopped()
serviceProvider.GetService(ALWAYS_INSTALLED_SERVICE).Status
.Should().NotBe(ServiceControllerStatus.Running);
//Act
serviceProvider.Stop(ALWAYS_INSTALLED_SERVICE);
//Assert
serviceProvider.GetService(ALWAYS_INSTALLED_SERVICE).Status
.Should().Be(ServiceControllerStatus.Stopped);

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming

using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Test.Common;

View File

@ -66,7 +66,7 @@ public void New_value_should_update_old_value_new_value()
Subject.SetValue(key, newValue);
var result = Subject.GetValue(key, "");
//Assert
result.Should().Be(newValue);
AllStoredModels.Should().HaveCount(1);
}
@ -142,7 +142,7 @@ public void config_properties_should_write_and_read_using_same_key()
var allProperties = typeof(ConfigService).GetProperties().Where(p => p.GetSetMethod() != null).ToList();
//Act
foreach (var propertyInfo in allProperties)
{
object value = null;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;
@ -18,7 +18,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class AcceptableSizeSpecificationFixture : CoreTest
{
private EpisodeParseResult parseResultMulti;
@ -84,10 +84,10 @@ public void IsAcceptableSize_true_single_episode_not_first_or_last_30_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeTrue();
}
@ -105,10 +105,10 @@ public void IsAcceptableSize_true_single_episode_not_first_or_last_60_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeTrue();
}
@ -126,10 +126,10 @@ public void IsAcceptableSize_false_single_episode_not_first_or_last_30_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeFalse();
}
@ -147,10 +147,10 @@ public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeFalse();
}
@ -168,10 +168,10 @@ public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
//Assert
result.Should().BeTrue();
}
@ -189,10 +189,10 @@ public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
//Assert
result.Should().BeTrue();
}
@ -210,10 +210,10 @@ public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
//Assert
result.Should().BeFalse();
}
@ -231,10 +231,10 @@ public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultMulti);
//Assert
result.Should().BeFalse();
}
@ -252,10 +252,10 @@ public void IsAcceptableSize_true_single_episode_first_30_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeTrue();
}
@ -273,10 +273,10 @@ public void IsAcceptableSize_true_single_episode_first_60_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeTrue();
}
@ -294,10 +294,10 @@ public void IsAcceptableSize_false_single_episode_first_30_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeFalse();
}
@ -315,10 +315,10 @@ public void IsAcceptableSize_false_single_episode_first_60_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeFalse();
}
@ -337,10 +337,10 @@ public void IsAcceptableSize_true_unlimited_30_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeTrue();
}
@ -359,10 +359,10 @@ public void IsAcceptableSize_true_unlimited_60_minute()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeTrue();
}
@ -382,10 +382,10 @@ public void IsAcceptableSize_should_treat_daily_series_as_single_episode()
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = Mocker.Resolve<AcceptableSizeSpecification>().IsSatisfiedBy(parseResultSingle);
//Assert
result.Should().BeTrue();
}

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;
@ -20,7 +20,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class AllowedReleaseGroupSpecificationFixture : CoreTest
{
private EpisodeParseResult parseResult;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;
@ -18,7 +18,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class CustomStartDateSpecificationFixture : CoreTest
{
private CustomStartDateSpecification _customStartDateSpecification;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;
@ -17,7 +17,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class LanguageSpecificationFixture : CoreTest
{
private EpisodeParseResult parseResult;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;
@ -18,7 +18,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class MonitoredEpisodeSpecificationFixture : CoreTest
{
private MonitoredEpisodeSpecification monitoredEpisodeSpecification;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Collections.Generic;
using System.Linq;
@ -16,7 +16,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityAllowedByProfileSpecificationFixture : CoreTest
{
private QualityAllowedByProfileSpecification _qualityAllowedByProfile;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using FluentAssertions;
@ -13,7 +13,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityUpgradeSpecificationFixture : CoreTest<QualityUpgradableSpecification>
{
public static object[] IsUpgradeTestCases =

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;
@ -18,7 +18,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class RetentionSpecificationFixture : CoreTest
{
private RetentionSpecification retentionSpecification;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -19,7 +19,7 @@
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class UpgradeDiskSpecificationFixture : CoreTest
{
private UpgradeDiskSpecification _upgradeDisk;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Collections.Generic;
using System.Linq;

View File

@ -12,7 +12,7 @@
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class EpisodeParseResultTest : CoreTest
{
[Test]

View File

@ -11,7 +11,7 @@
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class EpisodeStatusTest : CoreTest
{
[TestCase(1, false, false, EpisodeStatusType.NotAired)]

View File

@ -9,7 +9,7 @@
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class FluentTest : CoreTest
{
[TestCase(null, "def", "def")]
@ -86,11 +86,11 @@ public void ToBestDateTime_Before_Yesterday()
[Test]
public void ParentUriString_should_return_self_if_already_parent()
{
//Setup
var url = "http://www.nzbdrone.com";
var uri = new Uri(url);
//Act
var result = uri.ParentUriString();
//Resolve
@ -100,11 +100,11 @@ public void ParentUriString_should_return_self_if_already_parent()
[Test]
public void ParentUriString_should_return_parent_url_when_path_is_passed()
{
//Setup
var url = "http://www.nzbdrone.com/test/";
var uri = new Uri(url);
//Act
var result = uri.ParentUriString();
//Resolve
@ -114,11 +114,11 @@ public void ParentUriString_should_return_parent_url_when_path_is_passed()
[Test]
public void ParentUriString_should_return_parent_url_when_multiple_paths_are_passed()
{
//Setup
var url = "http://www.nzbdrone.com/test/test2";
var uri = new Uri(url);
//Act
var result = uri.ParentUriString();
//Resolve
@ -128,11 +128,11 @@ public void ParentUriString_should_return_parent_url_when_multiple_paths_are_pas
[Test]
public void ParentUriString_should_return_parent_url_when_url_with_query_string_is_passed()
{
//Setup
var url = "http://www.nzbdrone.com/test.aspx?test=10";
var uri = new Uri(url);
//Act
var result = uri.ParentUriString();
//Resolve
@ -142,11 +142,11 @@ public void ParentUriString_should_return_parent_url_when_url_with_query_string_
[Test]
public void ParentUriString_should_return_parent_url_when_url_with_path_and_query_strings_is_passed()
{
//Setup
var url = "http://www.nzbdrone.com/tester/test.aspx?test=10";
var uri = new Uri(url);
//Act
var result = uri.ParentUriString();
//Resolve
@ -156,11 +156,11 @@ public void ParentUriString_should_return_parent_url_when_url_with_path_and_quer
[Test]
public void ParentUriString_should_return_parent_url_when_url_with_query_strings_is_passed()
{
//Setup
var url = "http://www.nzbdrone.com/test.aspx?test=10&test2=5";
var uri = new Uri(url);
//Act
var result = uri.ParentUriString();
//Resolve
@ -170,10 +170,10 @@ public void ParentUriString_should_return_parent_url_when_url_with_query_strings
[Test]
public void MaxOrDefault_should_return_zero_when_collection_is_empty()
{
//Setup
//Act
var result = (new List<int>()).MaxOrDefault();
//Resolve
@ -183,10 +183,10 @@ public void MaxOrDefault_should_return_zero_when_collection_is_empty()
[Test]
public void MaxOrDefault_should_return_max_when_collection_is_not_empty()
{
//Setup
var list = new List<int> { 6, 4, 5, 3, 8, 10 };
//Act
var result = list.MaxOrDefault();
//Resolve
@ -196,10 +196,10 @@ public void MaxOrDefault_should_return_max_when_collection_is_not_empty()
[Test]
public void MaxOrDefault_should_return_zero_when_collection_is_null()
{
//Setup
List<int> list = null;
//Act
var result = list.MaxOrDefault();
//Resolve
@ -209,10 +209,10 @@ public void MaxOrDefault_should_return_zero_when_collection_is_null()
[Test]
public void Truncate_should_truncate_strings_to_max_specified_number_of_bytes()
{
//Setup
var str = ReadAllText("Files", "LongOverview.txt");
//Act
var resultString = str.Truncate(1000);
//Resolve
@ -223,10 +223,10 @@ public void Truncate_should_truncate_strings_to_max_specified_number_of_bytes()
[Test]
public void Truncate_should_not_truncate_string_shorter_than_max_bytes()
{
//Setup
var str = "Hello World";
//Act
var resultString = str.Truncate(1000);
//Resolve
@ -237,10 +237,10 @@ public void Truncate_should_not_truncate_string_shorter_than_max_bytes()
[Test]
public void MinOrDefault_should_return_zero_when_collection_is_empty()
{
//Setup
//Act
var result = (new List<int>()).MinOrDefault();
//Resolve
@ -250,10 +250,10 @@ public void MinOrDefault_should_return_zero_when_collection_is_empty()
[Test]
public void MinOrDefault_should_return_min_when_collection_is_not_empty()
{
//Setup
var list = new List<int> { 6, 4, 5, 3, 8, 10 };
//Act
var result = list.MinOrDefault();
//Resolve
@ -263,10 +263,10 @@ public void MinOrDefault_should_return_min_when_collection_is_not_empty()
[Test]
public void MinOrDefault_should_return_zero_when_collection_is_null()
{
//Setup
List<int> list = null;
//Act
var result = list.MinOrDefault();
//Resolve

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
using System.IO;

View File

@ -1,21 +1,12 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HelperTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SortHelperTest : CoreTest
{
[TestCase("The Office (US)", "Office (US)")]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -15,7 +15,7 @@
namespace NzbDrone.Core.Test.HelperTests.XElementHelperTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class ParseDayOfWeekFixture : CoreTest
{
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
using System.Xml.Linq;
@ -15,7 +15,7 @@
namespace NzbDrone.Core.Test.HelperTests.XElementHelperTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class XElementHelperTest : CoreTest
{
[Test]

View File

@ -119,10 +119,10 @@ public void should_skip_if_series_does_not_match_searched_series()
WithMisMatchedSeries();
//Act
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
//Assert
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
result.SearchHistoryItems.Should().NotContain(s => s.Success);
@ -147,10 +147,10 @@ public void should_skip_if_episode_was_already_downloaded()
WithQualityNeeded();
WithSuccessfulDownload();
//Act
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
//Assert
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
result.SearchHistoryItems.Should().Contain(s => s.Success);
@ -182,10 +182,10 @@ public void should_try_next_report_if_download_fails()
.Setup(s => s.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.SDTV)))
.Returns(true);
//Act
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
//Assert
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
result.SearchHistoryItems.Should().Contain(s => s.Success);
@ -215,10 +215,10 @@ public void should_return_valid_successes_when_one_or_more_downloaded()
.Setup(s => s.IsDownloadPermitted(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.Bluray1080p)))
.Returns(ReportRejectionReasons.None);
//Act
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
//Assert
result.Successes.Should().NotBeNull();
result.Successes.Should().NotBeEmpty();

View File

@ -21,7 +21,7 @@
namespace NzbDrone.Core.Test.IndexerTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class IndexerFixture : CoreTest
{
private void WithConfiguredIndexers()
@ -143,7 +143,7 @@ public void size_nzbsrus()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(OpenRead("Files", "Rss", "SizeParsing", "nzbsrus.xml"));
//Act
var parseResults = Mocker.Resolve<NzbsRUs>().FetchRss();
parseResults.Should().HaveCount(1);
@ -166,7 +166,7 @@ public void size_newznab()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(OpenRead("Files", "Rss", "SizeParsing", "newznab.xml"));
//Act
var parseResults = Mocker.Resolve<Newznab>().FetchRss();
parseResults[0].Size.Should().Be(1183105773);
@ -185,7 +185,7 @@ public void size_nzbindex()
.Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=", It.IsAny<NetworkCredential>()))
.Returns(OpenRead("Files", "Rss", "SizeParsing", "nzbindex.xml"));
//Act
var parseResults = Mocker.Resolve<NzbIndex>().FetchRss();
parseResults[0].Size.Should().Be(587328389);
@ -204,7 +204,7 @@ public void size_nzbclub()
.Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=", It.IsAny<NetworkCredential>()))
.Returns(OpenRead("Files", "Rss", "SizeParsing", "nzbclub.xml"));
//Act
var parseResults = Mocker.Resolve<NzbClub>().FetchRss();
parseResults.Should().HaveCount(2);
@ -220,7 +220,7 @@ public void size_omgwtfnzbs()
.Setup(h => h.DownloadStream("http://rss.omgwtfnzbs.org/rss-search.php?catid=19,20&user=MockedConfigValue&api=MockedConfigValue&eng=1", It.IsAny<NetworkCredential>()))
.Returns(OpenRead("Files", "Rss", "SizeParsing", "omgwtfnzbs.xml"));
//Act
var parseResults = Mocker.Resolve<Omgwtfnzbs>().FetchRss();
parseResults.Should().HaveCount(1);
@ -480,7 +480,7 @@ public void should_get_nzbInfoUrl_for_omgwtfnzbs()
.Setup(h => h.DownloadStream("http://rss.omgwtfnzbs.org/rss-search.php?catid=19,20&user=MockedConfigValue&api=MockedConfigValue&eng=1", It.IsAny<NetworkCredential>()))
.Returns(OpenRead("Files", "Rss", "SizeParsing", "omgwtfnzbs.xml"));
//Act
var parseResults = Mocker.Resolve<Omgwtfnzbs>().FetchRss();
parseResults.Should().HaveCount(1);

View File

@ -21,7 +21,7 @@
namespace NzbDrone.Core.Test.IndexerTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class NzbxFixture : CoreTest
{
[Test]
@ -31,7 +31,7 @@ public void should_get_size_when_parsing_recent_feed()
.Setup(h => h.DownloadString("https://nzbx.co/api/recent?category=tv", It.IsAny<NetworkCredential>()))
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_recent.json"));
//Act
var parseResults = Mocker.Resolve<Nzbx>().FetchRss();
parseResults.Should().HaveCount(1);
@ -45,7 +45,7 @@ public void should_get_size_when_parsing_search_results()
.Setup(h => h.DownloadString("https://nzbx.co/api/search?q=30+Rock+S01E01", It.IsAny<NetworkCredential>()))
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_search.json"));
//Act
var parseResults = Mocker.Resolve<Nzbx>().FetchEpisode("30 Rock", 1, 1);
parseResults.Should().HaveCount(1);
@ -91,7 +91,7 @@ public void should_get_postedDate_when_parsing_recent_feed()
.Setup(h => h.DownloadString("https://nzbx.co/api/recent?category=tv", It.IsAny<NetworkCredential>()))
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_recent.json"));
//Act
var parseResults = Mocker.Resolve<Nzbx>().FetchRss();
parseResults.Should().HaveCount(1);
@ -107,7 +107,7 @@ public void should_get_postedDate_when_parsing_search_results()
.Setup(h => h.DownloadString("https://nzbx.co/api/search?q=30+Rock+S01E01", It.IsAny<NetworkCredential>()))
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_search.json"));
//Act
var parseResults = Mocker.Resolve<Nzbx>().FetchEpisode("30 Rock", 1, 1);
parseResults.Should().HaveCount(1);
@ -121,7 +121,7 @@ public void should_name_nzb_properly()
.Setup(h => h.DownloadString("https://nzbx.co/api/recent?category=tv", It.IsAny<NetworkCredential>()))
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_recent.json"));
//Act
var parseResults = Mocker.Resolve<Nzbx>().FetchRss();
parseResults.Should().HaveCount(1);

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -18,7 +18,7 @@
namespace NzbDrone.Core.Test.Indexers
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class IndexerServiceTest : CoreTest<IndexerService>
{
[Test]

View File

@ -14,7 +14,7 @@
namespace NzbDrone.Core.Test.Indexers
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class NewznabProviderTest : CoreTest<NewznabService>
{
private void WithInvalidName()

View File

@ -44,10 +44,10 @@ public void should_delete_sandbox_before_update_if_folder_exists()
{
Mocker.GetMock<DiskProvider>().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(true);
//Act
StartUpdate();
//Assert
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true));
}
@ -56,10 +56,10 @@ public void should_not_delete_sandbox_before_update_if_folder_doesnt_exists()
{
Mocker.GetMock<DiskProvider>().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(false);
//Act
StartUpdate();
//Assert
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true), Times.Never());
}
@ -69,10 +69,10 @@ public void Should_download_update_package()
{
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
//Act
StartUpdate();
//Assert
Mocker.GetMock<HttpProvider>().Verify(
c => c.DownloadFile(updatePackage.Url, updateArchive));
}
@ -82,10 +82,10 @@ public void Should_extract_update_package()
{
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
//Act
StartUpdate();
//Assert
Mocker.GetMock<ArchiveProvider>().Verify(
c => c.ExtractArchive(updateArchive, SANDBOX_FOLDER));
}
@ -95,10 +95,10 @@ public void Should_copy_update_client_to_root_of_sandbox()
{
var updateClientFolder = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateClientFolder();
//Act
StartUpdate();
//Assert
Mocker.GetMock<DiskProvider>().Verify(
c => c.MoveDirectory(updateClientFolder, SANDBOX_FOLDER));
}
@ -106,16 +106,16 @@ public void Should_copy_update_client_to_root_of_sandbox()
[Test]
public void should_start_update_client()
{
//Setup
var updateClientPath = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateClientExePath();
Mocker.GetMock<EnvironmentProvider>()
.SetupGet(c => c.NzbDroneProcessIdFromEnviroment).Returns(12);
//Act
StartUpdate();
//Assert
Mocker.GetMock<ProcessProvider>().Verify(
c => c.Start(It.Is<ProcessStartInfo>(p =>
p.FileName == updateClientPath &&
@ -143,7 +143,7 @@ public void Should_download_and_extract_to_temp_folder()
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateSandboxFolder());
//Act
updateSubFolder.Exists.Should().BeFalse();
Mocker.Resolve<HttpProvider>();
@ -151,7 +151,7 @@ public void Should_download_and_extract_to_temp_folder()
Mocker.Resolve<ArchiveProvider>();
StartUpdate();
updateSubFolder.Refresh();
//Assert
updateSubFolder.Exists.Should().BeTrue();
updateSubFolder.GetDirectories("nzbdrone").Should().HaveCount(1);

View File

@ -28,7 +28,7 @@ private void WithEnableBacklogSearching()
[Test]
public void no_missing_epsiodes_should_not_trigger_any_search()
{
//Setup
var notification = new ProgressNotification("Backlog Search Job Test");
var episodes = new List<Episode>();
@ -39,10 +39,10 @@ public void no_missing_epsiodes_should_not_trigger_any_search()
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
Subject.Start(notification, null);
//Assert
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = It.IsAny<int>(), SeasonNumber = It.IsAny<int>() }),
Times.Never());
@ -53,7 +53,7 @@ public void no_missing_epsiodes_should_not_trigger_any_search()
[Test]
public void individual_missing_episode()
{
//Setup
var notification = new ProgressNotification("Backlog Search Job Test");
var series = Builder<Series>.CreateNew()
@ -74,10 +74,10 @@ public void individual_missing_episode()
Mocker.GetMock<EpisodeSearchJob>()
.Setup(s => s.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") == 1)));
//Act
Subject.Start(notification, null);
//Assert
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
Times.Once());
}
@ -85,7 +85,7 @@ public void individual_missing_episode()
[Test]
public void individual_missing_episodes_only()
{
//Setup
var notification = new ProgressNotification("Backlog Search Job Test");
var series = Builder<Series>.CreateNew()
@ -103,10 +103,10 @@ public void individual_missing_episodes_only()
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
Subject.Start(notification, null);
//Assert
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
Times.Exactly(episodes.Count));
}
@ -114,7 +114,7 @@ public void individual_missing_episodes_only()
[Test]
public void series_season_missing_episodes_only_mismatch_count()
{
//Setup
var notification = new ProgressNotification("Backlog Search Job Test");
var series = Builder<Series>.CreateNew()
@ -136,10 +136,10 @@ public void series_season_missing_episodes_only_mismatch_count()
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
//Act
Subject.Start(notification, null);
//Assert
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
Times.Exactly(episodes.Count));
}
@ -147,7 +147,7 @@ public void series_season_missing_episodes_only_mismatch_count()
[Test]
public void series_season_missing_episodes_only()
{
//Setup
var notification = new ProgressNotification("Backlog Search Job Test");
var series = Builder<Series>.CreateNew()
@ -170,10 +170,10 @@ public void series_season_missing_episodes_only()
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
//Act
Subject.Start(notification, null);
//Assert
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
Times.Once());
@ -182,7 +182,7 @@ public void series_season_missing_episodes_only()
[Test]
public void multiple_missing_episodes()
{
//Setup
var notification = new ProgressNotification("Backlog Search Job Test");
var series = Builder<Series>.CreateNew()
@ -212,10 +212,10 @@ public void multiple_missing_episodes()
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
//Act
Subject.Start(notification, null);
//Assert
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") >= 0 &&
d.GetPropertyValue<int>("SeasonNumber") >= 0)),
Times.Once());
@ -227,7 +227,7 @@ public void multiple_missing_episodes()
[Test]
public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored_series()
{
//Setup
var series = Builder<Series>.CreateListOfSize(2)
.TheFirst(1)
.With(s => s.Monitored = false)
@ -250,10 +250,10 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
var result = Subject.GetMissingForEnabledSeries();
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.Monitored);
result.Should().NotContain(s => !s.Series.Monitored);
@ -262,7 +262,7 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
[Test]
public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_series_when_backlog_searching_is_ignored()
{
//Setup
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
@ -289,10 +289,10 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
var result = Subject.GetMissingForEnabledSeries();
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
@ -302,7 +302,7 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
[Test]
public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inherit_series_when_backlog_searching_is_enabled()
{
//Setup
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
@ -329,10 +329,10 @@ public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inher
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
var result = Subject.GetMissingForEnabledSeries();
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -21,7 +21,7 @@
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class DiskScanJobTest : CoreTest
{
[Test]
@ -39,10 +39,10 @@ public void series_specific_scan_should_scan_series()
.Setup(p => p.Scan(series))
.Returns(new List<EpisodeFile>());
//Act
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), new { SeriesId = series.Id });
//Assert
Mocker.VerifyAllMocks();
}

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -20,7 +20,7 @@
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class ImportNewSeriesJobTest : CoreTest
{
[Test]
@ -69,10 +69,10 @@ public void import_new_series_succesful()
Mocker.GetMock<IMediaFileService>()
.Setup(s => s.GetFilesBySeries(It.IsAny<int>())).Returns(new List<EpisodeFile>());
//Act
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, null);
//Assert
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].Id)), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].Id)), Times.Once());
@ -123,10 +123,10 @@ public void failed_import_should_not_be_stuck_in_loop()
Mocker.GetMock<XemUpdateJob>()
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].Id)));
//Act
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, null);
//Assert
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].Id)), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].Id)), Times.Once());

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;

View File

@ -37,16 +37,16 @@ public void Setup()
[Test]
public void no_missing_epsiodes_should_not_trigger_any_search()
{
//Setup
var episodes = new List<Episode>();
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
Mocker.Resolve<RecentBacklogSearchJob>().Start(MockNotification, null);
//Assert
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(MockNotification, new { EpisodeId = It.IsAny<int>() }),
Times.Never());
}
@ -61,7 +61,7 @@ public void should_only_process_missing_episodes_from_the_last_30_days()
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
//Setup
var episodes = Builder<Episode>.CreateListOfSize(50)
.All()
.With(e => e.Series = series)
@ -92,10 +92,10 @@ public void should_only_process_missing_episodes_from_the_last_30_days()
Mocker.GetMock<EpisodeSearchJob>().Setup(c => c.Start(It.IsAny<ProgressNotification>(), It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)));
//Act
Mocker.Resolve<RecentBacklogSearchJob>().Start(MockNotification, null);
//Assert
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(It.IsAny<ProgressNotification>(), It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)),
Times.Exactly(40));
}
@ -103,7 +103,7 @@ public void should_only_process_missing_episodes_from_the_last_30_days()
[Test]
public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored_series()
{
//Setup
var series = Builder<Series>.CreateListOfSize(2)
.TheFirst(1)
.With(s => s.Monitored = false)
@ -126,10 +126,10 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
var result = Mocker.Resolve<RecentBacklogSearchJob>().GetMissingForEnabledSeries();
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.Monitored);
result.Should().NotContain(s => !s.Series.Monitored);
@ -138,7 +138,7 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
[Test]
public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_series_when_backlog_searching_is_ignored()
{
//Setup
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
@ -165,10 +165,10 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
var result = Mocker.Resolve<RecentBacklogSearchJob>().GetMissingForEnabledSeries();
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
@ -178,7 +178,7 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
[Test]
public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inherit_series_when_backlog_searching_is_enabled()
{
//Setup
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
@ -205,10 +205,10 @@ public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inher
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
var result = Mocker.Resolve<RecentBacklogSearchJob>().GetMissingForEnabledSeries();
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);

View File

@ -14,7 +14,7 @@
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class RssSyncJobTest : CoreTest
{
public void WithMinutes(int minutes)

View File

@ -16,7 +16,7 @@
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SeasonSearchJobTest : CoreTest
{
private List<Episode> _episodes;
@ -47,10 +47,10 @@ public void SeasonSearch_partial_season_success()
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
.Returns(_episodes.Select(e => e.EpisodeNumber).ToList());
//Act
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Once());
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }), Times.Never());
@ -63,10 +63,10 @@ public void SeasonSearch_partial_season_failure()
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
.Returns(new List<int>());
//Act
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
//Assert
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Once());
}
@ -91,10 +91,10 @@ public void SeasonSearch_should_not_search_for_episodes_that_havent_aired_yet_or
.Returns(new List<int>{1});
//Act
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 1 });
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Once());
}
@ -105,10 +105,10 @@ public void SeasonSearch_should_allow_searching_of_season_zero()
Mocker.GetMock<SearchProvider>()
.Setup(c => c.PartialSeasonSearch(notification, 1, 0)).Returns(new List<int>());
//Act
Mocker.Resolve<SeasonSearchJob>().Start(notification, new { SeriesId = 1, SeasonNumber = 0 });
//Assert
Mocker.GetMock<SearchProvider>().Verify(c => c.PartialSeasonSearch(notification, 1, 1), Times.Never());
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, new { EpisodeId = It.IsAny<int>() }), Times.Never());

View File

@ -14,7 +14,7 @@
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SeriesSearchJobTest : CoreTest
{
[Test]
@ -35,10 +35,10 @@ public void SeriesSearch_success()
Mocker.GetMock<SeasonSearchJob>()
.Setup(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == 1 && d.GetPropertyValue<int>("SeasonNumber") >= 0))).Verifiable();
//Act
Mocker.Resolve<SeriesSearchJob>().Start(notification, new { SeriesId = 1 });
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == 1 && d.GetPropertyValue<int>("SeasonNumber") >= 0)),
Times.Exactly(seasons.Count));
@ -56,10 +56,10 @@ public void SeriesSearch_no_seasons()
Mocker.GetMock<ISeasonRepository>()
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
//Act
Mocker.Resolve<SeriesSearchJob>().Start(notification, new { SeriesId = 1 });
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, new { SeriesId = 1, SeasonNumber = It.IsAny<int>() }),
Times.Never());

View File

@ -55,10 +55,10 @@ public void should_not_move_file_if_source_and_destination_are_the_same_path()
.Setup(e => e.BuildFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".avi"))
.Returns(fi);
//Act
var result = Subject.MoveEpisodeFile(file, false);
//Assert
result.Should().BeNull();
}

View File

@ -219,7 +219,7 @@
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetSceneTvdbMappingsFixture.cs" />
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetXemSeriesIdsFixture.cs" />
<Compile Include="Services\ParseErrorServiceFixture.cs" />
<Compile Include="HelperTests\SortHelperFixture.cs" />
<Compile Include="HelperTests\SortHelperTest.cs" />
<Compile Include="DecisionEngineTests\AcceptableSizeSpecificationFixture.cs" />
<Compile Include="Qualities\QualitySizeServiceFixture.cs" />
<Compile Include="ProviderTests\MisnamedProviderTest.cs" />

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.IO;
@ -17,7 +17,7 @@
namespace NzbDrone.Core.Test.OrganizerTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class MediaFileProvider_GetNewFilenameTest : CoreTest<FileNameBuilder>
{
private Series _series;
@ -45,7 +45,7 @@ public void Setup()
[Test]
public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
{
//Setup
@ -62,17 +62,17 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_Episode_Quality_1x05_Dash()
{
//Setup
@ -89,17 +89,17 @@ public void GetNewFilename_Episode_Quality_1x05_Dash()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("15x06 - City Sushi [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_Series_Quality_01x05_Space()
{
//Setup
@ -116,17 +116,17 @@ public void GetNewFilename_Series_Quality_01x05_Space()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park 05x06 [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_Series_s01e05_Space()
{
//Setup
@ -144,17 +144,17 @@ public void GetNewFilename_Series_s01e05_Space()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park s05e06", result);
}
[Test]
public void GetNewFilename_Series_Episode_s01e05_Periods()
{
//Setup
@ -171,17 +171,17 @@ public void GetNewFilename_Series_Episode_s01e05_Periods()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
}
[Test]
public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
{
//Setup
@ -198,17 +198,17 @@ public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV-720p]", result);
}
[Test]
public void GetNewFilename_S01E05_Dash()
{
//Setup
@ -226,17 +226,17 @@ public void GetNewFilename_S01E05_Dash()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("S15E06", result);
}
[Test]
public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
{
//Setup
@ -260,17 +260,17 @@ public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
.With(e => e.EpisodeNumber = 24)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
{
//Setup
@ -294,17 +294,17 @@ public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
.With(e => e.EpisodeNumber = 24)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("3x23x24 - Strawberries and Cream [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
{
//Setup
@ -328,17 +328,17 @@ public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
.With(e => e.EpisodeNumber = 24)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("3x23x24 Strawberries and Cream [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
{
//Setup
@ -362,17 +362,17 @@ public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
.With(e => e.EpisodeNumber = 24)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
}
[Test]
public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
{
//Setup
@ -396,17 +396,17 @@ public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
.With(e => e.EpisodeNumber = 24)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
}
[Test]
public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
{
//Setup
@ -430,17 +430,17 @@ public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
.With(e => e.EpisodeNumber = 24)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("3x23x24", result);
}
[Test]
public void GetNewFilename_should_append_proper_when_proper_and_append_quality_is_true()
{
//Setup
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
@ -455,17 +455,17 @@ public void GetNewFilename_should_append_proper_when_proper_and_append_quality_i
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = true });
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p] [Proper]");
}
[Test]
public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_quality_is_true()
{
//Setup
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
@ -480,17 +480,17 @@ public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_q
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
}
[Test]
public void GetNewFilename_should_not_append_proper_when_proper_and_append_quality_is_false()
{
//Setup
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
@ -505,17 +505,17 @@ public void GetNewFilename_should_not_append_proper_when_proper_and_append_quali
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = true });
//Assert
result.Should().Be("South Park - S15E06 - City Sushi");
}
[Test]
public void GetNewFilename_should_order_multiple_episode_files_in_numerical_order()
{
//Setup
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
@ -537,17 +537,17 @@ public void GetNewFilename_should_order_multiple_episode_files_in_numerical_orde
.With(e => e.EpisodeNumber = 7)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
}
[Test]
public void GetNewFilename_Series_Episode_Quality_S01E05_Period()
{
//Setup
@ -564,17 +564,17 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Period()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_Episode_Quality_1x05_Period()
{
//Setup
@ -591,17 +591,17 @@ public void GetNewFilename_Episode_Quality_1x05_Period()
.With(e => e.EpisodeNumber = 6)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
Assert.AreEqual("15x06.City Sushi [HDTV-720p]", result);
}
[Test]
public void GetNewFilename_UseSceneName_when_sceneName_isNull()
{
//Setup
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
@ -622,17 +622,17 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNull()
.With(e => e.Path = @"C:\Test\TV\30 Rock - S01E01 - Test")
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, episodeFile);
//Assert
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
}
[Test]
public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
{
//Setup
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
@ -653,17 +653,17 @@ public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
.With(e => e.Path = @"C:\Test\TV\30 Rock - S01E01 - Test")
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, episodeFile);
//Assert
result.Should().Be(episodeFile.SceneName);
}
[Test]
public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
{
//Setup
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
@ -685,17 +685,17 @@ public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
.With(e => e.EpisodeNumber = 7)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
}
[Test]
public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
{
//Setup
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
@ -717,17 +717,17 @@ public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
.With(e => e.EpisodeNumber = 7)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
}
[Test]
public void should_have_two_episodeTitles_when_distinct_count_is_two()
{
//Setup
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
@ -755,10 +755,10 @@ public void should_have_two_episodeTitles_when_distinct_count_is_two()
.With(e => e.EpisodeNumber = 8)
.Build();
//Act
string result = Subject.BuildFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
//Assert
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
}

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Linq;
@ -12,7 +12,7 @@
namespace NzbDrone.Core.Test.ParserTests
{
// ReSharper disable InconsistentNaming
[TestFixture]
public class ParserFixture : CoreTest
{

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Linq;
@ -10,7 +10,7 @@
namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityParserFixture : CoreTest
{
public static object[] QualityParserCases =

View File

@ -21,29 +21,29 @@
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
{
// ReSharper disable InconsistentNaming
public class CleanUpDropFolderFixture : CoreTest
{
[Test]
public void should_do_nothing_if_no_files_are_found()
{
//Setup
var folder = @"C:\Test\DropDir\The Office";
Mocker.GetMock<DiskProvider>().Setup(s => s.GetFiles(folder, SearchOption.AllDirectories))
.Returns(new string[0]);
//Act
Mocker.Resolve<DiskScanProvider>().CleanUpDropFolder(folder);
//Assert
Mocker.GetMock<IMediaFileService>().Verify(v => v.GetFileByPath(It.IsAny<string>()), Times.Never());
}
[Test]
public void should_do_nothing_if_no_conflicting_files_are_found()
{
//Setup
var folder = @"C:\Test\DropDir\The Office";
var filename = Path.Combine(folder, "NotAProblem.avi");
@ -58,10 +58,10 @@ public void should_do_nothing_if_no_conflicting_files_are_found()
Mocker.GetMock<IMediaFileService>().Setup(s => s.GetFileByPath(filename))
.Returns(() => null);
//Act
Mocker.Resolve<DiskScanProvider>().CleanUpDropFolder(folder);
//Assert
Mocker.GetMock<IMediaFileService>().Verify(v => v.GetFileByPath(filename), Times.Once());
Mocker.GetMock<ISeriesRepository>().Verify(v => v.Get(It.IsAny<int>()), Times.Never());
}
@ -69,7 +69,7 @@ public void should_do_nothing_if_no_conflicting_files_are_found()
[Test]
public void should_move_file_if_a_conflict_is_found()
{
//Setup
var folder = @"C:\Test\DropDir\The Office";
var filename = Path.Combine(folder, "Problem.avi");
var seriesId = 12345;
@ -119,10 +119,10 @@ public void should_move_file_if_a_conflict_is_found()
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveFile(episodeFile.Path, newFilePath));
//Act
Mocker.Resolve<DiskScanProvider>().CleanUpDropFolder(folder);
//Assert
Mocker.GetMock<IMediaFileService>().Verify(v => v.GetFileByPath(filename), Times.Once());
Mocker.GetMock<DiskProvider>().Verify(v => v.MoveFile(filename.NormalizePath(), newFilePath), Times.Once());
}

View File

@ -17,7 +17,7 @@
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
{
// ReSharper disable InconsistentNaming
public class GetVideoFilesFixture : CoreTest
{
private string[] _files;

View File

@ -18,7 +18,7 @@
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
{
// ReSharper disable InconsistentNaming
public class ImportFileFixture : CoreTest
{
public static object[] ImportTestCases =
@ -70,10 +70,10 @@ public void import_new_file_should_succeed()
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
//Assert
VerifyFileImport(result, Mocker, fakeEpisode, SIZE);
}
@ -97,10 +97,10 @@ public void import_new_file_with_better_same_quality_should_succeed(Quality curr
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
//Assert
VerifyFileImport(result, Mocker, fakeEpisode, SIZE);
}
@ -127,10 +127,10 @@ public void import_new_file_episode_has_same_or_better_quality_should_skip(strin
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, Mocker);
}
@ -146,10 +146,10 @@ public void import_unparsable_file_should_skip()
With80MBFile();
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, Mocker);
ExceptionVerification.ExpectedWarns(1);
}
@ -168,10 +168,10 @@ public void import_existing_file_should_skip()
With80MBFile();
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, Mocker);
}
@ -199,10 +199,10 @@ public void import_file_with_no_episode_in_db_should_skip()
.Returns(new List<Episode>());
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, Mocker);
}
@ -228,10 +228,10 @@ public void import_new_file_episode_has_better_quality_than_existing(string file
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, Mocker, fakeEpisode, SIZE);
Mocker.GetMock<RecycleBinProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Once());
}
@ -260,10 +260,10 @@ public void import_new_multi_part_file_episode_has_equal_or_better_quality_than_
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(fakeEpisodes);
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, Mocker, fakeEpisodes[0], SIZE);
Mocker.GetMock<RecycleBinProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Once());
}
@ -293,10 +293,10 @@ public void skip_import_new_multi_part_file_episode_existing_has_better_quality(
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(fakeEpisodes);
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, Mocker);
}
@ -331,10 +331,10 @@ public void import_new_multi_part_file_episode_replace_two_files()
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode1, fakeEpisode2 });
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, Mocker, fakeEpisode1, SIZE);
Mocker.GetMock<RecycleBinProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Exactly(2));
}
@ -360,10 +360,10 @@ public void should_import_new_episode_no_existing_episode_file()
Mocker.GetMock<IEpisodeService>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode});
//Act
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, Mocker, fakeEpisode, SIZE);
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Never());
}

View File

@ -12,7 +12,7 @@
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
{
// ReSharper disable InconsistentNaming
public class ScanFixture : CoreTest
{
[Test]
@ -44,7 +44,7 @@ public void series_should_update_the_last_scan_date()
[Test]
public void series_should_log_warning_if_path_doesnt_exist_on_disk()
{
//Setup
WithStrictMocker();
var series = Builder<Series>.CreateNew()
@ -56,10 +56,10 @@ public void series_should_log_warning_if_path_doesnt_exist_on_disk()
.Setup(c => c.FolderExists(series.Path))
.Returns(false);
//Act
Mocker.Resolve<DiskScanProvider>().Scan(series, series.Path);
//Assert
Mocker.VerifyAllMocks();
ExceptionVerification.ExpectedWarns(1);
}

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -21,13 +21,13 @@
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QueueFixture : CoreTest
{
[SetUp]
public void Setup()
{
//Setup
string sabHost = "192.168.5.55";
int sabPort = 2222;
string apikey = "5c770e3197e4fe763423ee7c392c25d1";

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -21,7 +21,7 @@
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SabProviderFixture : CoreTest
{
private const string url = "http://www.nzbclub.com/nzb_download.aspx?mid=1950232";
@ -53,7 +53,7 @@ public void add_url_should_format_request_properly()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&pp=3&cat=tv&nzbname=My+Series+Name+-+5x2-5x3+-+My+title+%5bBluray720p%5d+%5bProper%5d&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns("{ \"status\": true }");
//Act
Mocker.Resolve<SabProvider>().DownloadNzb(url, title, false).Should().BeTrue();
}
@ -62,7 +62,7 @@ public void add_by_url_should_detect_and_handle_sab_errors()
{
WithFailResponse();
//Act
Assert.Throws<ApplicationException>(() => Mocker.Resolve<SabProvider>().DownloadNzb(url, title, false).Should().BeFalse());
//ExceptionVerification.ExpectedErrors(1);
}
@ -70,7 +70,7 @@ public void add_by_url_should_detect_and_handle_sab_errors()
[Test]
public void should_be_able_to_get_categories_when_config_is_passed_in()
{
//Setup
const string host = "192.168.5.22";
const int port = 1111;
const string apikey = "5c770e3197e4fe763423ee7c392c25d2";
@ -83,10 +83,10 @@ public void should_be_able_to_get_categories_when_config_is_passed_in()
.Setup(s => s.DownloadString("http://192.168.5.22:1111/api?mode=get_cats&output=json&apikey=5c770e3197e4fe763423ee7c392c25d2&ma_username=admin2&ma_password=pass2"))
.Returns(ReadAllText("Files","Categories_json.txt"));
//Act
var result = Mocker.Resolve<SabProvider>().GetCategories(host, port, apikey, username, password);
//Assert
result.Should().NotBeNull();
result.categories.Should().NotBeEmpty();
}
@ -98,10 +98,10 @@ public void should_be_able_to_get_categories_using_config()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=get_cats&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(ReadAllText("Files","Categories_json.txt"));
//Act
var result = Mocker.Resolve<SabProvider>().GetCategories();
//Assert
result.Should().NotBeNull();
result.categories.Should().NotBeEmpty();
}
@ -113,10 +113,10 @@ public void GetHistory_should_return_a_list_with_items_when_the_history_has_item
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=history&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(ReadAllText("Files", "History.txt"));
//Act
var result = Mocker.Resolve<SabProvider>().GetHistory();
//Assert
result.Should().HaveCount(1);
}
@ -127,10 +127,10 @@ public void GetHistory_should_return_an_empty_list_when_the_queue_is_empty()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=history&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(ReadAllText("Files","HistoryEmpty.txt"));
//Act
var result = Mocker.Resolve<SabProvider>().GetHistory();
//Assert
result.Should().BeEmpty();
}
@ -141,7 +141,7 @@ public void GetHistory_should_return_an_empty_list_when_there_is_an_error_gettin
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=history&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(ReadAllText("Files","JsonError.txt"));
//Act
Assert.Throws<ApplicationException>(() => Mocker.Resolve<SabProvider>().GetHistory(), "API Key Incorrect");
}
@ -154,10 +154,10 @@ public void GetVersion_should_return_the_version_using_passed_in_values()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=version&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(response);
//Act
var result = Mocker.Resolve<SabProvider>().GetVersion("192.168.5.55", 2222, "5c770e3197e4fe763423ee7c392c25d1", "admin", "pass");
//Assert
result.Should().NotBeNull();
result.Version.Should().Be("0.6.9");
}
@ -171,10 +171,10 @@ public void GetVersion_should_return_the_version_using_saved_values()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=version&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(response);
//Act
var result = Mocker.Resolve<SabProvider>().GetVersion();
//Assert
result.Should().NotBeNull();
result.Version.Should().Be("0.6.9");
}
@ -188,10 +188,10 @@ public void Test_should_return_version_as_a_string()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=version&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(response);
//Act
var result = Mocker.Resolve<SabProvider>().Test("192.168.5.55", 2222, "5c770e3197e4fe763423ee7c392c25d1", "admin", "pass");
//Assert
result.Should().Be("0.6.9");
}
@ -220,7 +220,7 @@ public void downloadNzb_should_use_sabRecentTvPriority_when_recentEpisode_is_tru
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=1&pp=3&cat=tv&nzbname=My+Series+Name+-+5x2-5x3+-+My+title+%5bBluray720p%5d+%5bProper%5d&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns("{ \"status\": true }");
//Act
Mocker.Resolve<SabProvider>().DownloadNzb(url, title, true).Should().BeTrue();
Mocker.GetMock<HttpProvider>()
@ -242,7 +242,7 @@ public void downloadNzb_should_use_sabBackogTvPriority_when_recentEpisode_is_fal
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=-1&pp=3&cat=tv&nzbname=My+Series+Name+-+5x2-5x3+-+My+title+%5bBluray720p%5d+%5bProper%5d&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns("{ \"status\": true }");
//Act
Mocker.Resolve<SabProvider>().DownloadNzb(url, title, false).Should().BeTrue();
Mocker.GetMock<HttpProvider>()

View File

@ -14,7 +14,7 @@
using NzbDrone.Core.Model;
using NzbDrone.Core.Test.Framework;
// ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
{
@ -79,11 +79,11 @@ public void Download_report_should_publish_on_grab_event()
var parseResult = SetupParseResult();
//Act
Subject.DownloadReport(parseResult);
//Assert
Mocker.GetMock<SabProvider>()
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), true), Times.Once());

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using Moq;
@ -12,13 +12,13 @@
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class EventClientProviderTest : CoreTest
{
[Test]
public void SendNotification_true()
{
//Setup
var header = "NzbDrone Test";
@ -28,17 +28,17 @@ public void SendNotification_true()
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny<byte[]>())).Returns(true);
//Act
var result = Mocker.Resolve<EventClientProvider>().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void SendNotification_false()
{
//Setup
var header = "NzbDrone Test";
@ -48,17 +48,17 @@ public void SendNotification_false()
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny<byte[]>())).Returns(false);
//Act
var result = Mocker.Resolve<EventClientProvider>().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address);
//Assert
Assert.AreEqual(false, result);
}
[Test]
public void SendAction_Update_true()
{
//Setup
var path = @"C:\Test\TV\30 Rock";
@ -68,17 +68,17 @@ public void SendAction_Update_true()
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny<byte[]>())).Returns(true);
//Act
var result = Mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void SendAction_Update_false()
{
//Setup
var path = @"C:\Test\TV\30 Rock";
@ -88,10 +88,10 @@ public void SendAction_Update_false()
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny<byte[]>())).Returns(false);
//Act
var result = Mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
//Assert
Assert.AreEqual(false, result);
}
}

View File

@ -11,7 +11,7 @@
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
// ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test.ProviderTests
{
@ -22,52 +22,52 @@ public class GrowlProviderTest : CoreTest
[Test]
public void Register_should_add_new_application_to_local_growl_instance()
{
//Setup
WithStrictMocker();
//Act
Mocker.Resolve<GrowlProvider>().Register("localhost", 23053, "");
//Assert
Mocker.VerifyAllMocks();
}
[Test]
public void TestNotification_should_send_a_message_to_local_growl_instance()
{
//Setup
WithStrictMocker();
//Act
Mocker.Resolve<GrowlProvider>().TestNotification("localhost", 23053, "");
//Assert
Mocker.VerifyAllMocks();
}
[Test]
public void OnGrab_should_send_a_message_to_local_growl_instance()
{
//Setup
WithStrictMocker();
//Act
Mocker.Resolve<GrowlProvider>().SendNotification("Episode Grabbed", "Series Title - 1x05 - Episode Title", "GRAB", "localhost", 23053, "");
//Assert
Mocker.VerifyAllMocks();
}
[Test]
public void OnDownload_should_send_a_message_to_local_growl_instance()
{
//Setup
WithStrictMocker();
//Act
Mocker.Resolve<GrowlProvider>().SendNotification("Episode Downloaded", "Series Title - 1x05 - Episode Title", "DOWNLOAD", "localhost", 23053, "");
//Assert
Mocker.VerifyAllMocks();
}
}

View File

@ -21,7 +21,7 @@ public class MisnamedProviderTest : CoreTest
[Test]
public void no_misnamed_files()
{
//Setup
var series = Builder<Series>.CreateNew()
.With(s => s.Title = "SeriesTitle")
.Build();
@ -57,18 +57,18 @@ public void no_misnamed_files()
.Setup(c => c.BuildFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(0);
}
[Test]
public void all_misnamed_files()
{
//Setup
var series = Builder<Series>.CreateNew()
.With(s => s.Title = "SeriesTitle")
.Build();
@ -104,18 +104,18 @@ public void all_misnamed_files()
.Setup(c => c.BuildFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("New Title 2");
//Act
var totalItems = 0;
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(2);
}
[Test]
public void one_misnamed_file()
{
//Setup
var series = Builder<Series>.CreateNew()
.With(s => s.Title = "SeriesTitle")
.Build();
@ -151,11 +151,11 @@ public void one_misnamed_file()
.Setup(c => c.BuildFilename(new List<Episode> { episodes[1] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(1);
misnamedEpisodes[0].CurrentName.Should().Be("Title1");
misnamedEpisodes[0].ProperName.Should().Be("New Title 1");
@ -164,7 +164,7 @@ public void one_misnamed_file()
[Test]
public void misnamed_multi_episode_file()
{
//Setup
var series = Builder<Series>.CreateNew()
.With(s => s.Title = "SeriesTitle")
.Build();
@ -200,11 +200,11 @@ public void misnamed_multi_episode_file()
.Setup(c => c.BuildFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(1);
misnamedEpisodes[0].CurrentName.Should().Be("Title1");
misnamedEpisodes[0].ProperName.Should().Be("New Title 1");
@ -213,7 +213,7 @@ public void misnamed_multi_episode_file()
[Test]
public void no_misnamed_multi_episode_file()
{
//Setup
var series = Builder<Series>.CreateNew()
.With(s => s.Title = "SeriesTitle")
.Build();
@ -249,11 +249,11 @@ public void no_misnamed_multi_episode_file()
.Setup(c => c.BuildFilename(new List<Episode> { episodes[2] }, It.IsAny<Series>(), episodeFiles[1]))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(0);
}
}

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.IO;
@ -22,7 +22,7 @@
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class PlexProviderTest : CoreTest
{
private void WithSingleClient()
@ -49,7 +49,7 @@ public void WithClientCredentials()
[Test]
public void GetSectionKeys_should_return_single_section_key_when_only_one_show_section()
{
//Setup
var response = "<MediaContainer size=\"1\" mediaTagPrefix=\"/system/bundle/media/flags/\" mediaTagVersion=\"1329809559\" title1=\"Plex Library\" identifier=\"com.plexapp.plugins.library\"><Directory refreshing=\"0\" key=\"5\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory></MediaContainer>";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -57,10 +57,10 @@ public void GetSectionKeys_should_return_single_section_key_when_only_one_show_s
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadStream("http://localhost:32400/library/sections", null))
.Returns(stream);
//Act
var result = Mocker.Resolve<PlexProvider>().GetSectionKeys("localhost:32400");
//Assert
result.Should().HaveCount(1);
result.First().Should().Be(5);
}
@ -68,7 +68,7 @@ public void GetSectionKeys_should_return_single_section_key_when_only_one_show_s
[Test]
public void GetSectionKeys_should_return_single_section_key_when_only_one_show_section_with_other_sections()
{
//Setup
var response = "<MediaContainer size=\"1\" mediaTagPrefix=\"/system/bundle/media/flags/\" mediaTagVersion=\"1329809559\" title1=\"Plex Library\" identifier=\"com.plexapp.plugins.library\"><Directory refreshing=\"0\" key=\"5\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory><Directory refreshing=\"0\" key=\"7\" type=\"movie\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory></MediaContainer>";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -76,10 +76,10 @@ public void GetSectionKeys_should_return_single_section_key_when_only_one_show_s
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadStream("http://localhost:32400/library/sections", null))
.Returns(stream);
//Act
var result = Mocker.Resolve<PlexProvider>().GetSectionKeys("localhost:32400");
//Assert
result.Should().HaveCount(1);
result.First().Should().Be(5);
}
@ -87,7 +87,7 @@ public void GetSectionKeys_should_return_single_section_key_when_only_one_show_s
[Test]
public void GetSectionKeys_should_return_multiple_section_keys_when_there_are_multiple_show_sections()
{
//Setup
var response = "<MediaContainer size=\"1\" mediaTagPrefix=\"/system/bundle/media/flags/\" mediaTagVersion=\"1329809559\" title1=\"Plex Library\" identifier=\"com.plexapp.plugins.library\"><Directory refreshing=\"0\" key=\"5\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory><Directory refreshing=\"0\" key=\"6\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory></MediaContainer>";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -95,10 +95,10 @@ public void GetSectionKeys_should_return_multiple_section_keys_when_there_are_mu
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadStream("http://localhost:32400/library/sections", null))
.Returns(stream);
//Act
var result = Mocker.Resolve<PlexProvider>().GetSectionKeys("localhost:32400");
//Assert
result.Should().HaveCount(2);
result.First().Should().Be(5);
result.Last().Should().Be(6);
@ -107,7 +107,7 @@ public void GetSectionKeys_should_return_multiple_section_keys_when_there_are_mu
[Test]
public void UpdateSection_should_update_section()
{
//Setup
var response = "";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -115,17 +115,17 @@ public void UpdateSection_should_update_section()
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString("http://localhost:32400/library/sections/5/refresh"))
.Returns(response);
//Act
Mocker.Resolve<PlexProvider>().UpdateSection("localhost:32400", 5);
//Assert
}
[Test]
public void Notify_should_send_notification_for_single_client_when_only_one_is_configured()
{
//Setup
WithSingleClient();
const string header = "Test Header";
@ -137,17 +137,17 @@ public void Notify_should_send_notification_for_single_client_when_only_one_is_c
fakeHttp.Setup(s => s.DownloadString(expectedUrl))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(expectedUrl), Times.Once());
}
[Test]
public void Notify_should_send_notifcation_to_all_configured_clients()
{
//Setup
WithMultipleClients();
const string header = "Test Header";
@ -157,17 +157,17 @@ public void Notify_should_send_notifcation_to_all_configured_clients()
fakeHttp.Setup(s => s.DownloadString(It.IsAny<string>()))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(It.IsAny<string>()), Times.Exactly(2));
}
[Test]
public void Notify_should_send_notification_with_credentials_when_configured()
{
//Setup
WithSingleClient();
WithClientCredentials();
@ -180,17 +180,17 @@ public void Notify_should_send_notification_with_credentials_when_configured()
fakeHttp.Setup(s => s.DownloadString(expectedUrl, "plex", "plex"))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(expectedUrl, "plex", "plex"), Times.Once());
}
[Test]
public void Notify_should_send_notification_with_credentials_when_configured_for_all_clients()
{
//Setup
WithMultipleClients();
WithClientCredentials();
@ -201,10 +201,10 @@ public void Notify_should_send_notification_with_credentials_when_configured_for
fakeHttp.Setup(s => s.DownloadString(It.IsAny<string>(), "plex", "plex"))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(It.IsAny<string>(), "plex", "plex"), Times.Exactly(2));
}
}

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;
@ -12,7 +12,7 @@
namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class GetFolderNameWithStatusFixture : CoreTest
{
[TestCase(@"c:\_NzbDrone_InvalidEpisode_Title", @"c:\_UnknownSeries_Title", PostDownloadStatusType.UnknownSeries)]

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming
using System;
using System.Collections.Generic;
using System.IO;
@ -99,11 +99,11 @@ public void should_continue_processing_if_folder_is_tagged_and_not_fresh()
var droppedFolder = new DirectoryInfo(TempFolder + "\\_test\\");
droppedFolder.Create();
//Act
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null).Verifiable();
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
ExceptionVerification.IgnoreWarns();
}
@ -118,10 +118,10 @@ public void should_search_for_series_using_title_without_status()
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns<Series>(null).Verifiable();
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
ExceptionVerification.IgnoreWarns();
}
@ -160,20 +160,20 @@ public void should_search_for_series_using_file_name()
[Ignore("Disabled tagging")]
public void when_series_isnt_found_folder_should_be_tagged_as_unknown_series()
{
//Setup
WithStrictMocker();
WithOldWrite();
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - S01E01 - Episode Title");
var taggedFolder = @"C:\Test\Unsorted TV\_UnknownSeries_The Office - S01E01 - Episode Title";
//Act
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns<Series>(null);
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
ExceptionVerification.ExpectedWarns(1);
}
@ -182,7 +182,7 @@ public void when_series_isnt_found_folder_should_be_tagged_as_unknown_series()
[Ignore("Disabled tagging")]
public void when_no_files_are_imported_folder_should_be_tagged_with_parse_error()
{
//Setup
WithStrictMocker();
WithOldWrite();
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - S01E01 - Episode Title");
@ -193,7 +193,7 @@ public void when_no_files_are_imported_folder_should_be_tagged_with_parse_error(
.With(s => s.Title = "The Office")
.Build();
//Act
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns(fakeSeries);
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(new List<EpisodeFile>());
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
@ -202,7 +202,7 @@ public void when_no_files_are_imported_folder_should_be_tagged_with_parse_error(
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
ExceptionVerification.ExpectedWarns(1);
}
@ -212,7 +212,7 @@ public void when_no_files_are_imported_folder_should_be_tagged_with_parse_error(
[Ignore("Disabled tagging")]
public void when_no_file_are_imported_and_folder_size_isnt_small_enought_folder_should_be_tagged_unknown()
{
//Setup
WithStrictMocker();
WithOldWrite();
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - Season 01");
@ -228,7 +228,7 @@ public void when_no_file_are_imported_and_folder_size_isnt_small_enought_folder_
.With(f => f.SeriesId = fakeSeries.Id)
.Build().ToList();
//Act
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns(fakeSeries);
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
@ -237,7 +237,7 @@ public void when_no_file_are_imported_and_folder_size_isnt_small_enought_folder_
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
ExceptionVerification.ExpectedWarns(1);
}
@ -248,17 +248,17 @@ public void when_no_file_are_imported_and_folder_size_isnt_small_enought_folder_
[TestCase("\\Test\\_UnknownSeries_The Office - S01E01 - Episode Title")]
public void folder_shouldnt_be_tagged_with_same_tag_again(string path)
{
//Setup
var droppedFolder = new DirectoryInfo(TempFolder + path);
droppedFolder.Create();
WithOldWrite();
//Act
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<DiskProvider>().Verify(c => c.MoveDirectory(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
}
@ -266,7 +266,7 @@ public void folder_shouldnt_be_tagged_with_same_tag_again(string path)
[Test]
public void folder_should_not_be_tagged_if_existing_tag_is_diffrent()
{
//Setup
WithOldWrite();
var droppedFolder = new DirectoryInfo(TempFolder + @"\_UnknownEpisode_The Office - S01E01 - Episode Title");
droppedFolder.Create();
@ -276,10 +276,10 @@ public void folder_should_not_be_tagged_if_existing_tag_is_diffrent()
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<DiskProvider>().Verify(c => c.MoveDirectory(droppedFolder.FullName, taggedFolder), Times.Never());
ExceptionVerification.IgnoreWarns();
@ -288,7 +288,7 @@ public void folder_should_not_be_tagged_if_existing_tag_is_diffrent()
[Test]
public void when_files_are_imported_and_folder_is_small_enough_dir_should_be_deleted()
{
//Setup
WithStrictMocker();
WithLotsOfFreeDiskSpace();
@ -304,10 +304,10 @@ public void when_files_are_imported_and_folder_is_small_enough_dir_should_be_del
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true);
Mocker.GetMock<DiskProvider>().Setup(s => s.IsFolderLocked(droppedFolder.FullName)).Returns(false);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.VerifyAllMocks();
}
@ -326,10 +326,10 @@ public void all_imported_files_should_be_moved()
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true);
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
Mocker.GetMock<IMoveEpisodeFiles>().Verify(c => c.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true),
Times.Exactly(fakeEpisodeFiles.Count));
Mocker.VerifyAllMocks();
@ -361,11 +361,11 @@ public void should_logError_and_return_if_size_exceeds_free_space()
.Setup(s => s.FreeDiskSpace(series.Path))
.Returns(9);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(downloadName);
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(series, downloadName.FullName), Times.Never());
ExceptionVerification.ExpectedErrors(1);
}
@ -388,11 +388,11 @@ public void should_process_if_free_disk_space_exceeds_size()
.Setup(s => s.GetDirectorySize(downloadName.FullName))
.Returns(8);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(downloadName);
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(fakeSeries, downloadName.FullName), Times.Once());
}
@ -412,11 +412,11 @@ public void should_process_if_free_disk_space_equals_size()
.Setup(s => s.FreeDiskSpace(It.IsAny<string>()))
.Returns(10);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(downloadName);
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(fakeSeries, downloadName.FullName), Times.Once());
}

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming
using System;
using System.Collections.Generic;
using System.IO;
@ -78,10 +78,10 @@ public void ProcessDropFolder_should_only_process_folders_that_arent_known_serie
.Setup(c => c.FolderExists(It.IsAny<String>()))
.Returns(true);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDropFolder(@"C:\drop\");
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(It.IsAny<Series>(), subFolders[0]), Times.Once());
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(It.IsAny<Series>(), subFolders[1]), Times.Never());
Mocker.GetMock<DiskScanProvider>().Verify(c => c.Scan(It.IsAny<Series>(), subFolders[2]), Times.Once());
@ -121,11 +121,11 @@ public void ProcessDropFolder_should_process_individual_video_files_in_drop_fold
.Setup(c => c.FolderExists(It.IsAny<String>()))
.Returns(true);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessDropFolder(@"C:\drop\");
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.ImportFile(It.IsAny<Series>(), It.IsAny<String>()), Times.Exactly(4));
}
}

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming
using System;
using System.Collections.Generic;
using System.IO;
@ -96,11 +96,11 @@ public void should_continue_processing_if_not_fresh()
var file = Path.Combine(TempFolder, "test.avi");
//Act
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null).Verifiable();
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(file);
//Assert
Mocker.GetMock<ISeriesRepository>().Verify(s => s.GetByTitle(It.IsAny<String>()), Times.Once());
ExceptionVerification.IgnoreWarns();
}
@ -112,11 +112,11 @@ public void should_return_if_series_is_not_found()
var file = Path.Combine(TempFolder, "test.avi");
//Act
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null);
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(file);
//Assert
Mocker.GetMock<DiskProvider>().Verify(s => s.GetSize(It.IsAny<String>()), Times.Never());
ExceptionVerification.IgnoreWarns();
}
@ -132,10 +132,10 @@ public void should_move_file_if_imported()
WithValidSeries();
WithImportedFile(file);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(file);
//Assert
Mocker.GetMock<IMoveEpisodeFiles>().Verify(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true), Times.Once());
ExceptionVerification.IgnoreWarns();
}
@ -166,11 +166,11 @@ public void should_logError_and_return_if_size_exceeds_free_space()
.Setup(s => s.FolderExists(series.Path))
.Returns(true);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(downloadName);
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.ImportFile(series, downloadName), Times.Never());
ExceptionVerification.ExpectedErrors(1);
}
@ -191,11 +191,11 @@ public void should_process_if_free_disk_space_exceeds_size()
.Setup(s => s.GetSize(downloadName))
.Returns(8);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(downloadName);
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.ImportFile(fakeSeries, downloadName), Times.Once());
}
@ -214,11 +214,11 @@ public void should_process_if_free_disk_space_equals_size()
.Setup(s => s.FreeDiskSpace(It.IsAny<string>()))
.Returns(10);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(downloadName);
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.ImportFile(fakeSeries, downloadName), Times.Once());
}
@ -233,11 +233,11 @@ public void should_return_if_series_Path_doesnt_exist()
.Setup(s => s.FolderExists(fakeSeries.Path))
.Returns(false);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(downloadName);
//Assert
ExceptionVerification.ExpectedWarns(1);
}
@ -252,11 +252,11 @@ public void should_skip_if_file_is_in_use_by_another_process()
.Setup(s => s.IsFileLocked(It.Is<FileInfo>(f => f.FullName == downloadName)))
.Returns(true);
//Act
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(downloadName);
//Assert
Mocker.GetMock<DiskScanProvider>().Verify(c => c.ImportFile(fakeSeries, downloadName), Times.Never());
}
}

View File

@ -12,7 +12,7 @@
using NzbDrone.Test.Common.AutoMoq;
using Prowlin;
// ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test.ProviderTests
{
@ -28,26 +28,26 @@ public class ProwlProviderTest : CoreTest
[Test]
public void Verify_should_return_true_for_a_valid_apiKey()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().Verify(_apiKey);
//Assert
result.Should().BeTrue();
}
[Test]
public void Verify_should_return_false_for_an_invalid_apiKey()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().Verify(_badApiKey);
//Assert
ExceptionVerification.ExpectedWarns(1);
result.Should().BeFalse();
}
@ -55,26 +55,26 @@ public void Verify_should_return_false_for_an_invalid_apiKey()
[Test]
public void SendNotification_should_return_true_for_a_valid_apiKey()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey);
//Assert
result.Should().BeTrue();
}
[Test]
public void SendNotification_should_return_false_for_an_invalid_apiKey()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _badApiKey);
//Assert
ExceptionVerification.ExpectedWarns(1);
result.Should().BeFalse();
}
@ -82,65 +82,65 @@ public void SendNotification_should_return_false_for_an_invalid_apiKey()
[Test]
public void SendNotification_should_alert_with_high_priority()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (High)", _apiKey, NotificationPriority.High);
//Assert
result.Should().BeTrue();
}
[Test]
public void SendNotification_should_alert_with_VeryLow_priority()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (VeryLow)", _apiKey, NotificationPriority.VeryLow);
//Assert
result.Should().BeTrue();
}
[Test]
public void SendNotification_should_have_a_call_back_url()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey, NotificationPriority.Normal, "http://www.nzbdrone.com");
//Assert
result.Should().BeTrue();
}
[Test]
public void SendNotification_should_return_true_for_two_valid_apiKey()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _apiKey2);
//Assert
result.Should().BeTrue();
}
[Test]
public void SendNotification_should_return_true_for_valid_apiKey_with_bad_apiKey()
{
//Setup
WithStrictMocker();
//Act
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _badApiKey);
//Assert
result.Should().BeTrue();
}
}

View File

@ -1,26 +1,17 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class CleanupFixture : CoreTest
{
private const string RecycleBin = @"C:\Test\RecycleBin";

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -20,7 +20,7 @@
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class DeleteDirectoryFixture : CoreTest
{
private void WithRecycleBin()

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -20,7 +20,7 @@
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class DeleteFileFixture : CoreTest
{
private void WithRecycleBin()

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -20,7 +20,7 @@
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class EmptyFixture : CoreTest
{
private const string RecycleBin = @"C:\Test\RecycleBin";

View File

@ -15,7 +15,7 @@
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SceneMappingProviderTest : DbTest
{
private const string SceneMappingUrl = "http://services.nzbdrone.com/SceneMapping/Active";
@ -46,7 +46,7 @@ private void WithErrorDownloadingJson()
public void GetSceneName_exists()
{
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.CleanTitle = "laworder")
.With(f => f.TvdbId = 12345)
@ -56,10 +56,10 @@ public void GetSceneName_exists()
Db.Insert(fakeMap);
//Act
var sceneName = Mocker.Resolve<SceneMappingService>().GetSceneName(fakeMap.TvdbId);
//Assert
Assert.AreEqual(fakeMap.SceneName, sceneName);
}
@ -67,7 +67,7 @@ public void GetSceneName_exists()
public void GetSeriesId_exists()
{
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
@ -77,10 +77,10 @@ public void GetSeriesId_exists()
Db.Insert(fakeMap);
//Act
var seriesId = Mocker.Resolve<SceneMappingService>().GetTvDbId(fakeMap.CleanTitle);
//Assert
Assert.AreEqual(fakeMap.TvdbId, seriesId);
}
@ -88,7 +88,7 @@ public void GetSeriesId_exists()
public void GetSceneName_null()
{
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
@ -98,10 +98,10 @@ public void GetSceneName_null()
Db.Insert(fakeMap);
//Act
var sceneName = Mocker.Resolve<SceneMappingService>().GetSceneName(54321);
//Assert
Assert.AreEqual(null, sceneName);
}
@ -109,7 +109,7 @@ public void GetSceneName_null()
public void GetSeriesId_null()
{
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
@ -118,10 +118,10 @@ public void GetSeriesId_null()
Db.Insert(fakeMap);
//Act
var seriesId = Mocker.Resolve<SceneMappingService>().GetTvDbId("notlaworder");
//Assert
Assert.AreEqual(null, seriesId);
}
@ -130,7 +130,7 @@ public void GetSceneName_multiple_clean_names()
{
//Test that ensures a series with clean names (office, officeus) can be looked up by seriesId
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.CleanTitle = "office")
.With(f => f.TvdbId = 12345)
@ -150,10 +150,10 @@ public void GetSceneName_multiple_clean_names()
Db.Insert(fakeMap);
Db.Insert(fakeMap2);
//Act
var sceneName = Mocker.Resolve<SceneMappingService>().GetSceneName(fakeMap.TvdbId);
//Assert
Assert.AreEqual(fakeMap.SceneName, sceneName);
}
@ -179,17 +179,17 @@ public void UpdateMappings_should_add_all_mappings_to_database()
{
WithValidJson();
//Act
Mocker.Resolve<SceneMappingService>().UpdateMappings();
//Assert
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
}
[Test]
public void UpdateMappings_should_overwrite_existing_mappings()
{
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
@ -199,17 +199,17 @@ public void UpdateMappings_should_overwrite_existing_mappings()
WithValidJson();
Db.Insert(fakeMap);
//Act
Mocker.Resolve<SceneMappingService>().UpdateMappings();
//Assert
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
}
[Test]
public void UpdateMappings_should_not_delete_if_csv_download_fails()
{
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
@ -219,10 +219,10 @@ public void UpdateMappings_should_not_delete_if_csv_download_fails()
WithErrorDownloadingJson();
Db.Insert(fakeMap);
//Act
Mocker.Resolve<SceneMappingService>().UpdateMappings();
//Assert
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
}

View File

@ -1,6 +1,4 @@
// ReSharper disable RedundantUsingDirective
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Autofac;
@ -15,7 +13,7 @@
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class TvDbProviderTest : CoreTest
{
private TvDbProxy tvDbProxy;
@ -56,10 +54,10 @@ public void successful_search(string title)
[Test]
public void no_search_result()
{
//act
var result = tvDbProxy.SearchSeries(Guid.NewGuid().ToString());
//assert
result.Should().BeEmpty();
}
@ -67,11 +65,9 @@ public void no_search_result()
[Test]
public void none_unique_season_episode_number()
{
//act
var result = tvDbProxy.GetEpisodes(75978);//Family guy
//Asserts that when episodes are grouped by Season/Episode each group contains maximum of
//one item.
result.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
.Max(e => e.Count()).Should().Be(1);

View File

@ -1,5 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
using System.IO;
@ -16,7 +15,7 @@
namespace NzbDrone.Core.Test.ProviderTests.TvRageProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class GetSeriesFixture : CoreTest
{
private const string showinfo = "http://services.tvrage.com/feeds/showinfo.php?key=NW4v0PSmQIoVmpbASLdD&sid=";
@ -25,14 +24,14 @@ private void WithEmptyResults()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(showinfo)), null))
.Returns(new FileStream(@".\Files\TVRage\SeriesInfo_empty.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
.Returns(OpenRead("Files", "TVRage", "SeriesInfo_empty.xml"));
}
private void WithOneResult()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(showinfo)), null))
.Returns(new FileStream(@".\Files\TVRage\SeriesInfo_one.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
.Returns(OpenRead("Files", "TVRage", "SeriesInfo_one.xml"));
}
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -14,7 +14,7 @@
namespace NzbDrone.Core.Test.ProviderTests.TvRageProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class GetUtcOffsetFixture : CoreTest
{
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -16,7 +16,7 @@
namespace NzbDrone.Core.Test.ProviderTests.TvRageProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class SearchSeriesFixture : CoreTest
{
private const string search = "http://services.tvrage.com/feeds/full_search.php?show=";
@ -25,21 +25,21 @@ private void WithEmptyResults()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(search)), null))
.Returns(new FileStream(@".\Files\TVRage\SearchResults_empty.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
.Returns(OpenRead("Files", "TVRage", "SearchResults_empty.xml"));
}
private void WithManyResults()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(search)), null))
.Returns(new FileStream(@".\Files\TVRage\SearchResults_many.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
.Returns(OpenRead("Files", "TVRage", "SearchResults_many.xml"));
}
private void WithOneResult()
{
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadStream(It.Is<String>(u => u.StartsWith(search)), null))
.Returns(new FileStream(@".\Files\TVRage\SearchResults_one.xml", FileMode.Open, FileAccess.Read, FileShare.Read));
.Returns(OpenRead("Files", "TVRage", "earchResults_one.xml"));
}
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Linq;
@ -19,7 +19,7 @@
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class XbmcProviderTest : CoreTest
{
private string EdenActivePlayers;
@ -52,42 +52,42 @@ private void WithAllPlayersActive()
[Test]
public void JsonError_true()
{
//Setup
var response = "{\"error\":{\"code\":-32601,\"message\":\"Method not found.\"},\"id\":10,\"jsonrpc\":\"2.0\"}";
//Act
var result = Mocker.Resolve<XbmcProvider>().CheckForJsonError(response);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void JsonError_true_empty_response()
{
//Setup
var response = String.Empty;
//Act
var result = Mocker.Resolve<XbmcProvider>().CheckForJsonError(response);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void JsonError_false()
{
//Setup
var reposnse = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":3}}";
//Act
var result = Mocker.Resolve<XbmcProvider>().CheckForJsonError(reposnse);
//Assert
Assert.AreEqual(false, result);
}
@ -102,10 +102,10 @@ public void GetJsonVersionIntOnly(int number)
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(message);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetJsonVersion("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().Be(new XbmcVersion(number));
}
@ -122,10 +122,10 @@ public void GetJsonVersionFrodo(int major, int minor, int patch)
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(message);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetJsonVersion("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().Be(new XbmcVersion(major, minor, patch));
}
@ -138,10 +138,10 @@ public void GetJsonVersion_error()
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(message);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetJsonVersion("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().Be(new XbmcVersion(0));
}
@ -155,7 +155,7 @@ public void GetJsonVersion_error()
[TestCase(true, false, true)]
public void GetActivePlayersDharma(bool audio, bool picture, bool video)
{
//Setup
var message = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"audio\":"
+ audio.ToString().ToLower()
+ ",\"picture\":"
@ -168,10 +168,10 @@ public void GetActivePlayersDharma(bool audio, bool picture, bool video)
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(message);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetActivePlayersDharma("localhost:8080", "xbmc", "xbmc");
//Assert
Assert.AreEqual(audio, result["audio"]);
Assert.AreEqual(picture, result["picture"]);
Assert.AreEqual(video, result["video"]);
@ -180,34 +180,34 @@ public void GetActivePlayersDharma(bool audio, bool picture, bool video)
[Test]
public void GetActivePlayersEden_should_be_empty_when_no_active_players()
{
//Setup
WithNoActivePlayers();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(EdenActivePlayers);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetActivePlayersEden("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().BeEmpty();
}
[Test]
public void GetActivePlayersEden_should_have_active_video_player()
{
//Setup
WithVideoPlayerActive();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(EdenActivePlayers);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetActivePlayersEden("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().HaveCount(1);
result.First().Type.Should().Be("video");
}
@ -215,17 +215,17 @@ public void GetActivePlayersEden_should_have_active_video_player()
[Test]
public void GetActivePlayersEden_should_have_active_audio_player()
{
//Setup
WithAudioPlayerActive();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(EdenActivePlayers);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetActivePlayersEden("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().HaveCount(1);
result.First().Type.Should().Be("audio");
}
@ -233,17 +233,17 @@ public void GetActivePlayersEden_should_have_active_audio_player()
[Test]
public void GetActivePlayersEden_should_have_active_picture_player()
{
//Setup
WithPicturePlayerActive();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(EdenActivePlayers);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetActivePlayersEden("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().HaveCount(1);
result.First().Type.Should().Be("picture");
}
@ -251,17 +251,17 @@ public void GetActivePlayersEden_should_have_active_picture_player()
[Test]
public void GetActivePlayersEden_should_have_all_players_active()
{
//Setup
WithAllPlayersActive();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(EdenActivePlayers);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetActivePlayersEden("localhost:8080", "xbmc", "xbmc");
//Assert
result.Should().HaveCount(3);
result.Select(a => a.PlayerId).Distinct().Should().HaveCount(3);
result.Select(a => a.Type).Distinct().Should().HaveCount(3);
@ -270,7 +270,7 @@ public void GetActivePlayersEden_should_have_all_players_active()
[Test]
public void GetTvShowsJson()
{
//Setup
var message = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"limits\":{\"end\":5,\"start\":0,\"total\":5},\"tvshows\":[{\"file\":\"smb://HOMESERVER/TV/7th Heaven/\",\"imdbnumber\":\"73928\",\"label\":\"7th Heaven\",\"tvshowid\":3},{\"file\":\"smb://HOMESERVER/TV/8 Simple Rules/\",\"imdbnumber\":\"78461\",\"label\":\"8 Simple Rules\",\"tvshowid\":4},{\"file\":\"smb://HOMESERVER/TV/24-7 Penguins-Capitals- Road to the NHL Winter Classic/\",\"imdbnumber\":\"213041\",\"label\":\"24/7 Penguins/Capitals: Road to the NHL Winter Classic\",\"tvshowid\":1},{\"file\":\"smb://HOMESERVER/TV/30 Rock/\",\"imdbnumber\":\"79488\",\"label\":\"30 Rock\",\"tvshowid\":2},{\"file\":\"smb://HOMESERVER/TV/90210/\",\"imdbnumber\":\"82716\",\"label\":\"90210\",\"tvshowid\":5}]}}";
@ -279,10 +279,10 @@ public void GetTvShowsJson()
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(message);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetTvShowsJson("localhost:8080", "xbmc", "xbmc");
//Assert
Assert.AreEqual(5, result.Count);
result.Should().Contain(s => s.ImdbNumber == 79488);
}
@ -290,7 +290,7 @@ public void GetTvShowsJson()
[Test]
public void Notify_true()
{
//Setup
WithStrictMocker();
var header = "NzbDrone Test";
@ -303,17 +303,17 @@ public void Notify_true()
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
fakeEventClient.Setup(s => s.SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", "localhost")).Returns(true);
//Act
Mocker.Resolve<XbmcProvider>().Notify(header, message);
//Assert
Mocker.VerifyAllMocks();
}
[Test]
public void SendCommand()
{
//Setup
WithStrictMocker();
var host = "localhost:8080";
@ -327,10 +327,10 @@ public void SendCommand()
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.DownloadString(url, username, password)).Returns("Ok\n");
//Act
var result = Mocker.Resolve<XbmcProvider>().SendCommand(host, command, username, username);
//Assert
Mocker.VerifyAllMocks();
Assert.AreEqual("Ok\n", result);
}
@ -338,7 +338,7 @@ public void SendCommand()
[Test]
public void GetXbmcSeriesPath_true()
{
//Setup
WithStrictMocker();
var queryResult = @"<xml><record><field>smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/</field></record></xml>";
@ -360,10 +360,10 @@ public void GetXbmcSeriesPath_true()
</html>");
fakeHttp.Setup(s => s.DownloadString(query, username, password)).Returns(queryResult);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
//Assert
Mocker.VerifyAllMocks();
Assert.AreEqual("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/", result);
}
@ -371,7 +371,7 @@ public void GetXbmcSeriesPath_true()
[Test]
public void GetXbmcSeriesPath_false()
{
//Setup
WithStrictMocker();
var queryResult = @"<xml></xml>";
@ -393,10 +393,10 @@ public void GetXbmcSeriesPath_false()
</html>");
fakeHttp.Setup(s => s.DownloadString(query, username, password)).Returns(queryResult);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
//Assert
Mocker.VerifyAllMocks();
Assert.AreEqual("", result);
}
@ -404,7 +404,7 @@ public void GetXbmcSeriesPath_false()
[Test]
public void GetXbmcSeriesPath_special_characters()
{
//Setup
WithStrictMocker();
var queryResult = @"<xml><record><field>smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/</field></record></xml>";
@ -426,10 +426,10 @@ public void GetXbmcSeriesPath_special_characters()
</html>");
fakeHttp.Setup(s => s.DownloadString(query, username, password)).Returns(queryResult);
//Act
var result = Mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
//Assert
Mocker.VerifyAllMocks();
result.Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/");
}
@ -437,7 +437,7 @@ public void GetXbmcSeriesPath_special_characters()
[Test]
public void Clean()
{
//Setup
WithStrictMocker();
var fakeConfig = Mocker.GetMock<IConfigService>();
@ -446,10 +446,10 @@ public void Clean()
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(CleanLibrary(video))")).Returns(true);
//Act
Mocker.Resolve<XbmcProvider>().Clean();
//Assert
Mocker.VerifyAllMocks();
}
@ -472,10 +472,10 @@ public void UpdateWithHttp_Single()
fakeHttp.Setup(s => s.DownloadString(queryUrl, username, password)).Returns(queryResult);
fakeHttp.Setup(s => s.DownloadString(url, username, password));
//Act
Mocker.Resolve<XbmcProvider>().UpdateWithHttp(fakeSeries, host, username, password);
//Assert
Mocker.VerifyAllMocks();
}
@ -498,17 +498,17 @@ public void UpdateWithHttp_All()
fakeHttp.Setup(s => s.DownloadString(queryUrl, username, password)).Returns(queryResult);
fakeHttp.Setup(s => s.DownloadString(url, username, password));
//Act
Mocker.Resolve<XbmcProvider>().UpdateWithHttp(fakeSeries, host, username, password);
//Assert
Mocker.VerifyAllMocks();
}
[Test]
public void UpdateWithJsonBuiltIn_Single()
{
//Setup
var host = "localhost:8080";
@ -531,17 +531,17 @@ public void UpdateWithJsonBuiltIn_Single()
fakeHttp.Setup(s => s.DownloadString(url, username, password)).Returns("<html><li>OK</html>");
//Act
var result = Mocker.Resolve<XbmcProvider>().UpdateWithJsonExecBuiltIn(fakeSeries, host, username, password);
//Assert
result.Should().BeTrue();
}
[Test]
public void UpdateWithJsonBuiltIn_All()
{
//Setup
var host = "localhost:8080";
@ -567,10 +567,10 @@ public void UpdateWithJsonBuiltIn_All()
//var fakeEventClient = Mocker.GetMock<EventClientProvider>();
//fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video))"));
//Act
var result = Mocker.Resolve<XbmcProvider>().UpdateWithJsonExecBuiltIn(fakeSeries, host, username, password);
//Assert
result.Should().BeTrue();
}
@ -599,10 +599,10 @@ public void UpdateWithJsonVideoLibraryScan_Single()
.Contains("\"params\":{\"directory\":\"smb://HOMESERVER/TV/30Rock/\"}"))))
.Returns("{\"id\":55,\"jsonrpc\":\"2.0\",\"result\":\"OK\"}");
//Act
var result = Mocker.Resolve<XbmcProvider>().UpdateWithJsonVideoLibraryScan(fakeSeries, host, username, password);
//Assert
result.Should().BeTrue();
}
@ -631,10 +631,10 @@ public void UpdateWithJsonVideoLibraryScan_All()
.Contains("\"params\":{\"directory\":\"smb://HOMESERVER/TV/30Rock/\"}"))))
.Returns("{\"id\":55,\"jsonrpc\":\"2.0\",\"result\":\"OK\"}");
//Act
var result = Mocker.Resolve<XbmcProvider>().UpdateWithJsonVideoLibraryScan(fakeSeries, host, username, password);
//Assert
result.Should().BeTrue();
}
}

View File

@ -17,7 +17,7 @@
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class GetSceneTvdbMappingsFixture : CoreTest
{
private void WithFailureJson()

View File

@ -17,7 +17,7 @@
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class GetXemSeriesIdsFixture : CoreTest
{
private void WithFailureJson()

View File

@ -7,7 +7,7 @@
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityFixture : CoreTest
{
public static object[] FromIntCases =

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective
using System.Linq;
using System;
@ -14,7 +14,7 @@
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityProfileFixture : CoreTest<QualityProfileService>
{
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective
using System.Linq;
using System.Collections.Generic;
@ -12,7 +12,7 @@
namespace NzbDrone.Core.Test.Qualities
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualitySizeServiceFixture : CoreTest<QualitySizeService>
{
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -16,7 +16,7 @@
namespace NzbDrone.Core.Test.RootFolderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class FreeSpaceOnDrivesFixture : CoreTest<RootFolderService>
{
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;
@ -15,7 +15,7 @@
namespace NzbDrone.Core.Test.RootFolderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class RootFolderServiceFixture : CoreTest<RootFolderService>
{
[SetUp]

View File

@ -1,5 +1,5 @@
/*
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
@ -23,7 +23,7 @@
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class EpisodeProviderTest : ObjectDbTest
{
[Test]
@ -38,10 +38,10 @@ public void GetEpisodes_exists()
Db.Insert(fakeSeries);
Db.InsertMany(fakeEpisodes);
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1);
//Assert
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
}
@ -62,10 +62,10 @@ public void GetEpisodes_by_season_episode_exists()
Db.Insert(fakeSeries);
Db.Insert(fakeEpisodes);
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(fakeSeries.Id, 2, 1);
//Assert
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes);
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
}
@ -75,10 +75,10 @@ public void GetEpisodes_by_season_episode_doesnt_exists()
{
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
//Assert
episode.Should().BeNull();
}
@ -96,10 +96,10 @@ public void GetEpisode_with_EpisodeFile()
Db.InsertMany(fakeEpisodes);
Db.Insert(fakeFile);
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1);
//Assert
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
episode.EpisodeFile.Should().NotBeNull();
@ -120,7 +120,7 @@ public void GetEpisodes_invalid_series()
Db.InsertMany(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().GetEpisode(1);
}
@ -141,10 +141,10 @@ public void GetEpisodesBySeason_success()
Db.Insert(fakeSeries);
Db.InsertMany(episodes);
//Act
var seasonEposodes = Mocker.Resolve<EpisodeService>().GetEpisodesBySeason(12, 2);
//Assert
Db.Fetch<Episode>().Should().HaveCount(10);
seasonEposodes.Should().HaveCount(5);
}
@ -174,10 +174,10 @@ public void RefreshEpisodeInfo_emptyRepo()
.Setup(c => c.GetSeries(seriesId, true, false))
.Returns(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var actualCount = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList().Count;
Mocker.GetMock<TvDbProvider>().VerifyAll();
actualCount.Should().Be(episodeCount);
@ -209,10 +209,10 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
.Returns(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var storedEpisodes = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
storedEpisodes.Should().HaveCount(10);
storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(7);
@ -249,10 +249,10 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null_for_existing_e
.Setup(c => c.GetSeries(seriesId, true, false))
.Returns(fakeTvDbEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var storedEpisodes = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
storedEpisodes.Should().HaveCount(1);
storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(1);
@ -287,10 +287,10 @@ public void RefreshEpisodeInfo_ignore_episode_zero()
.Returns(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
Mocker.GetMock<TvDbProvider>().VerifyAll();
result.Should().HaveCount(episodeCount);
@ -326,10 +326,10 @@ public void RefreshEpisodeInfo_should_skip_future_episodes_with_no_title()
.Returns(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
result.Should().HaveCount(episodeCount - 3);
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title) || c.AirDate < DateTime.Now);
@ -364,10 +364,10 @@ public void RefreshEpisodeInfo_should_skip_older_than_1900_year_episodes_with_no
.Returns(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
result.Should().HaveCount(episodeCount - 3);
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title) || c.AirDate < DateTime.Now);
@ -397,10 +397,10 @@ public void RefreshEpisodeInfo_should_add_future_episodes_with_title()
.Returns(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
result.Should().HaveSameCount(fakeEpisodes.Episodes);
}
@ -430,10 +430,10 @@ public void RefreshEpisodeInfo_should_add_old_episodes_with_no_title()
.Returns(fakeEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
result.Should().HaveSameCount(fakeEpisodes.Episodes);
}
@ -468,10 +468,10 @@ public void RefreshEpisodeInfo_ignore_season_zero()
.Setup(s => s.IsIgnored(seriesId, 0))
.Returns(true);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
Mocker.GetMock<TvDbProvider>().VerifyAll();
result.Should().HaveCount(episodeCount);
@ -499,10 +499,10 @@ public void new_episodes_only_calls_Insert()
.Returns(currentEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
Mocker.GetMock<IDatabase>().Verify(c => c.InsertMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 5)), Times.Once());
Mocker.GetMock<IDatabase>().Verify(c => c.Update(It.IsAny<IEnumerable<Episode>>()), Times.Never());
@ -533,10 +533,10 @@ public void existing_episodes_only_calls_Update()
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
.Returns(currentEpisodes);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
Mocker.GetMock<IDatabase>().Verify(c => c.InsertMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 0)), Times.Once());
Mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 5)), Times.Once());
Mocker.VerifyAllMocks();
@ -566,10 +566,10 @@ public void should_try_to_get_existing_episode_using_tvdbid_first()
.Setup(c => c.GetSeries(seriesId, true, false))
.Returns(fakeTvDbResult);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(fakeEpisodeList), Times.Once());
}
@ -607,10 +607,10 @@ public void should_try_to_get_existing_episode_using_tvdbid_first_then_season_ep
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
.Returns(new List<Episode> { localEpisode });
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
Mocker.VerifyAllMocks();
Mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(new List<Episode> { localEpisode }), Times.Once());
}
@ -654,10 +654,10 @@ public void existing_episodes_keep_their_episodeId_file_id()
.Setup(c => c.UpdateMany(It.IsAny<IEnumerable<Episode>>()))
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes = ep.ToList());
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
updatedEpisodes.Should().HaveSameCount(tvdbSeries.Episodes);
updatedEpisodes.Should().OnlyContain(c => c.Id == 99);
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 69);
@ -703,10 +703,10 @@ public void existing_episodes_remote_their_episodeId_file_id_when_episode_number
.Setup(c => c.UpdateMany(It.IsAny<IEnumerable<Episode>>()))
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes = ep.ToList());
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 0);
}
@ -749,10 +749,10 @@ public void existing_episodes_remote_their_episodeId_file_id_when_season_number_
.Setup(c => c.UpdateMany(It.IsAny<IEnumerable<Episode>>()))
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes = ep.ToList());
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 0);
}
@ -801,10 +801,10 @@ public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season()
.Setup(s => s.IsIgnored(seriesId, It.IsAny<int>()))
.Returns(true);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
Mocker.GetMock<TvDbProvider>().VerifyAll();
result.Should().HaveCount(episodeCount);
@ -826,7 +826,7 @@ public void Add_daily_show_episodes()
var seriesRepo = Mocker.Resolve<ISeriesRepository>();
const int tvDbSeriesId = 71256;
//act
var seriesProvider = Mocker.Resolve<SeriesService>();
seriesProvider.AddSeries("Test Series", "c:\\test\\", tvDbSeriesId, 1, null);
@ -836,7 +836,7 @@ public void Add_daily_show_episodes()
var episodeProvider = Mocker.Resolve<EpisodeService>();
episodeProvider.RefreshEpisodeInfo(seriesRepo.Get(tvDbSeriesId));
//assert
var episodes = episodeProvider.GetEpisodeBySeries(tvDbSeriesId);
episodes.Should().NotBeEmpty();
}
@ -846,10 +846,10 @@ public void GetEpisode_by_Season_Episode_none_existing()
{
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
//Assert
episode.Should().BeNull();
}
@ -867,10 +867,10 @@ public void GetEpisode_by_Season_Episode_with_EpisodeFile()
Db.InsertMany(fakeEpisodes);
Db.Insert(fakeFile);
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
//Assert
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
episode.EpisodeFile.Should().NotBeNull();
@ -888,10 +888,10 @@ public void GetEpisode_by_Season_Episode_without_EpisodeFile()
Db.Insert(fakeSeries);
Db.InsertMany(fakeEpisodes);
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
//Assert
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
episode.EpisodeFile.Should().BeNull();
@ -911,10 +911,10 @@ public void GetEpisode_by_AirDate_with_EpisodeFile()
Db.InsertMany(fakeEpisodes);
Db.Insert(fakeFile);
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
//Assert
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
episode.EpisodeFile.Should().NotBeNull();
@ -932,10 +932,10 @@ public void GetEpisode_by_AirDate_without_EpisodeFile()
Db.InsertMany(fakeEpisodes);
Db.Insert(fakeSeries);
//Act
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
//Assert
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
episode.EpisodeFile.Should().BeNull();
@ -983,10 +983,10 @@ public void AddEpisode_episode_is_ignored_when_full_season_is_ignored()
.Setup(s => s.IsIgnored(newEpisode.SeriesId, newEpisode.SeasonNumber))
.Returns(true);
//Act
Mocker.Resolve<EpisodeService>().AddEpisode(newEpisode);
//Assert
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
episodesInDb.Should().HaveCount(5);
@ -1017,10 +1017,10 @@ public void AddEpisode_episode_is_not_ignored_when_full_season_is_not_ignored()
.With(e => e.Ignored = false)
.Build();
//Act
Mocker.Resolve<EpisodeService>().AddEpisode(newEpisode);
//Assert
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
episodesInDb.Should().HaveCount(5);
@ -1053,10 +1053,10 @@ public void AddEpisode_episode_is_not_ignored_when_not_full_season_is_not_ignore
.With(e => e.Ignored = false)
.Build();
//Act
Mocker.Resolve<EpisodeService>().AddEpisode(newEpisode);
//Assert
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
episodesInDb.Should().HaveCount(5);
@ -1079,10 +1079,10 @@ public void IgnoreEpisode_Ignore()
episodes.ForEach(c => Db.Insert(c));
//Act
Mocker.Resolve<EpisodeService>().SetEpisodeIgnore(1, true);
//Assert
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
episodesInDb.Should().HaveCount(4);
@ -1105,10 +1105,10 @@ public void IgnoreEpisode_RemoveIgnore()
episodes.ForEach(c => Db.Insert(c));
//Act
Mocker.Resolve<EpisodeService>().SetEpisodeIgnore(1, false);
//Assert
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
episodesInDb.Should().HaveCount(4);
@ -1150,10 +1150,10 @@ public void EpisodesWithoutFiles_no_specials()
Db.InsertMany(episodes);
Db.InsertMany(specials);
//Act
var missingFiles = Mocker.Resolve<EpisodeService>().EpisodesWithoutFiles(false);
//Assert
missingFiles.Should().HaveCount(1);
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(1);
@ -1194,10 +1194,10 @@ public void EpisodesWithoutFiles_with_specials()
Db.InsertMany(episodes);
Db.InsertMany(specials);
//Act
var missingFiles = Mocker.Resolve<EpisodeService>().EpisodesWithoutFiles(true);
//Assert
missingFiles.Should().HaveCount(2);
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(2);
@ -1231,10 +1231,10 @@ public void EpisodesWithFiles_success()
Db.Insert(episodeFile);
Db.InsertMany(episodes);
//Act
var withFiles = Mocker.Resolve<EpisodeService>().EpisodesWithFiles();
//Assert
withFiles.Should().HaveCount(2);
withFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(0);
withFiles.Where(e => e.EpisodeFile == null).Should().HaveCount(0);
@ -1268,10 +1268,10 @@ public void EpisodesWithFiles_no_files()
Db.Insert(series);
Db.InsertMany(episodes);
//Act
var withFiles = Mocker.Resolve<EpisodeService>().EpisodesWithFiles();
//Assert
withFiles.Should().HaveCount(0);
Mocker.VerifyAllMocks();
@ -1296,10 +1296,10 @@ public void GetEpisodesByFileId_multi_episodes()
Db.Insert(series);
Db.InsertMany(fakeEpisodes);
//Act
var episodes = Mocker.Resolve<EpisodeService>().GetEpisodesByFileId(12345);
//Assert
episodes.Should().HaveCount(2);
Mocker.VerifyAllMocks();
}
@ -1322,10 +1322,10 @@ public void GetEpisodesByFileId_single_episode()
Db.Insert(series);
Db.Insert(fakeEpisode);
//Act
var episodes = Mocker.Resolve<EpisodeService>().GetEpisodesByFileId(12345);
//Assert
episodes.Should().HaveCount(1);
episodes.First().ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisode);
Mocker.VerifyAllMocks();
@ -1344,10 +1344,10 @@ public void IsFirstOrLastEpisodeInSeason_false()
Db.InsertMany(fakeEpisodes);
//Act
var result = Mocker.Resolve<EpisodeService>().IsFirstOrLastEpisodeOfSeason(10, 1, 5);
//Assert
result.Should().BeFalse();
}
@ -1364,10 +1364,10 @@ public void IsFirstOrLastEpisodeInSeason_true_first()
Db.InsertMany(fakeEpisodes);
//Act
var result = Mocker.Resolve<EpisodeService>().IsFirstOrLastEpisodeOfSeason(10, 1, 1);
//Assert
result.Should().BeFalse();
}
@ -1384,10 +1384,10 @@ public void IsFirstOrLastEpisodeInSeason_true_last()
Db.InsertMany(fakeEpisodes);
//Act
var result = Mocker.Resolve<EpisodeService>().IsFirstOrLastEpisodeOfSeason(10, 1, 10);
//Assert
result.Should().BeFalse();
}
@ -1418,10 +1418,10 @@ public void SetPostDownloadStatus(string folderName, PostDownloadStatusType post
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("officeus")).Returns(fakeSeries);
//Act
Mocker.Resolve<EpisodeService>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.Id).ToList(), postDownloadStatus);
//Assert
var result = Db.Fetch<Episode>();
result.Where(e => e.PostDownloadStatus == postDownloadStatus).Count().Should().Be(episodeCount);
}
@ -1450,10 +1450,10 @@ public void SetPostDownloadStatus_Invalid_EpisodeId()
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("officeus")).Returns(fakeSeries);
//Act
Mocker.Resolve<EpisodeService>().SetPostDownloadStatus(new List<int> { 300 }, postDownloadStatus);
//Assert
var result = Db.Fetch<Episode>();
result.Where(e => e.PostDownloadStatus == postDownloadStatus).Count().Should().Be(0);
}
@ -1501,10 +1501,10 @@ public void RefreshEpisodeInfo_should_ignore_episode_zero_except_if_season_one()
.Setup(c => c.GetSeries(seriesId, true, false))
.Returns(tvdbSeries);
//Act
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
//Assert
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
result.Should().HaveCount(episodeCount);
result.Where(e => e.Ignored).Should().HaveCount(episodeCount - 1);

View File

@ -1,5 +1,5 @@
/*
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
@ -15,7 +15,7 @@
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class EpisodeProviderTest_GetEpisodesByParseResult : ObjectDbTest
{
private IEpisodeService episodeService;
@ -160,9 +160,9 @@ public void none_existing_multi_episode_should_not_return_or_add_anything()
[Test]
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_null()
{
//Act
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult());
//Assert
episodes.Should().NotBeNull();
episodes.Should().BeEmpty();
}
@ -170,9 +170,9 @@ public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_nu
[Test]
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_empty()
{
//Act
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult { EpisodeNumbers = new List<int>() });
//Assert
episodes.Should().NotBeNull();
episodes.Should().BeEmpty();
}
@ -184,10 +184,10 @@ public void should_return_single_episode_when_air_date_is_provided()
Db.Insert(fakeSeries);
Db.Insert(fakeDailyEpisode);
//Act
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
//Assert
episodes.Should().HaveCount(1);
VerifyEpisode(episodes[0], fakeDailyEpisode);
@ -199,7 +199,7 @@ public void should_not_add_episode_when_episode_doesnt_exist()
{
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
//Assert
episodes.Should().HaveCount(0);
Db.Fetch<Episode>().Should().HaveCount(0);
}

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using FizzWare.NBuilder;
@ -10,7 +10,7 @@
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class GetEpisodeBySceneNumberFixture : DbTest
{
private Series _series;

View File

@ -8,7 +8,7 @@
namespace NzbDrone.Core.Test.TvTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class QualityModelFixture : CoreTest
{
[Test]

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Linq;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System.Linq;
using System;

View File

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.Collections.Generic;

View File

@ -57,10 +57,10 @@ public void should_call_update_with_corret_path()
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(12))
.Returns(new ProcessInfo() { StartPath = ProcessPath });
//Act
_program.Start(new[] { "12", "" });
//Assert
Mocker.GetMock<UpdateProvider>().Verify(c => c.Start(@"C:\NzbDrone"), Times.Once());
}

View File

@ -59,10 +59,10 @@ public void should_stop_nzbdrone_service_if_installed_and_running()
WithInstalledService();
WithServiceRunning(true);
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
Mocker.GetMock<ServiceProvider>().Verify(c => c.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
}
@ -72,20 +72,20 @@ public void should_not_stop_nzbdrone_service_if_installed_but_not_running()
WithInstalledService();
WithServiceRunning(false);
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
Mocker.GetMock<ServiceProvider>().Verify(c => c.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Never());
}
[Test]
public void should_not_stop_nzbdrone_service_if_service_isnt_installed()
{
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
Mocker.GetMock<ServiceProvider>().Verify(c => c.Stop(It.IsAny<string>()), Times.Never());
}
@ -98,10 +98,10 @@ public void should_kill_nzbdrone_process_if_running()
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProccessName))
.Returns(proccesses);
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
Mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[0].Id), Times.Once());
Mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[1].Id), Times.Once());
}
@ -113,10 +113,10 @@ public void should_not_kill_nzbdrone_process_not_running()
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProccessName))
.Returns(new List<ProcessInfo>());
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
Mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(It.IsAny<int>()), Times.Never());
}
@ -125,7 +125,7 @@ public void should_stop_orphan_iisexpress_instances()
{
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
Mocker.GetMock<IHostController>().Verify(c => c.StopServer(), Times.Once());
}
@ -157,10 +157,10 @@ public void should_restore_if_update_fails()
.Setup(c => c.CopyDirectory(UPDATE_FOLDER, TARGET_FOLDER))
.Throws(new IOException());
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
Mocker.GetMock<DiskProvider>()
.Verify(c => c.CopyDirectory(BACKUP_FOLDER, TARGET_FOLDER), Times.Once());
ExceptionVerification.ExpectedFatals(1);
@ -172,10 +172,10 @@ public void should_restart_service_if_service_was_running()
WithInstalledService();
WithServiceRunning(true);
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
VerifyServiceRestart();
}
@ -185,10 +185,10 @@ public void should_restart_process_if_service_was_not_running()
WithInstalledService();
WithServiceRunning(false);
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
VerifyProcessRestart();
}
@ -202,10 +202,10 @@ public void should_restart_service_if_service_was_running_and_update_fails()
.Setup(c => c.CopyDirectory(UPDATE_FOLDER, TARGET_FOLDER))
.Throws(new IOException());
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
VerifyServiceRestart();
ExceptionVerification.ExpectedFatals(1);
}
@ -220,10 +220,10 @@ public void should_restart_process_if_service_was_not_running_and_update_fails()
.Setup(c => c.CopyDirectory(UPDATE_FOLDER, TARGET_FOLDER))
.Throws(new IOException());
//Act
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
//Assert
VerifyProcessRestart();
ExceptionVerification.ExpectedFatals(1);
}

View File

@ -1,4 +1,4 @@
// ReSharper disable InconsistentNaming

using System;
using System.IO;