All tests now use base class Mocker

This commit is contained in:
kay.one 2011-12-14 20:15:53 -08:00
parent ab29a114d1
commit 1b45a85f3f
39 changed files with 1002 additions and 1010 deletions

View File

@ -19,15 +19,13 @@ namespace NzbDrone.App.Test
[Test]
public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
{
var mocker = new AutoMoqer();
var processMock = mocker.GetMock<ProcessProvider>();
var processMock = Mocker.GetMock<ProcessProvider>();
processMock.Setup(c => c.GetCurrentProcess())
.Returns(Builder<ProcessInfo>.CreateNew().With(c => c.Priority == ProcessPriorityClass.Normal).Build());
processMock.Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
var subject = mocker.Resolve<MonitoringProvider>();
var subject = Mocker.Resolve<MonitoringProvider>();
//Act

View File

@ -46,13 +46,13 @@ namespace NzbDrone.App.Test
[Test]
public void Route_should_call_install_service_when_application_mode_is_install()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var serviceProviderMock = mocker.GetMock<ServiceProvider>();
WithStrictMocker();
var serviceProviderMock = Mocker.GetMock<ServiceProvider>();
serviceProviderMock.Setup(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME));
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
Mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
serviceProviderMock.Verify(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
}
@ -61,13 +61,13 @@ namespace NzbDrone.App.Test
[Test]
public void Route_should_call_uninstall_service_when_application_mode_is_uninstall()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var serviceProviderMock = mocker.GetMock<ServiceProvider>();
WithStrictMocker();
var serviceProviderMock = Mocker.GetMock<ServiceProvider>();
serviceProviderMock.Setup(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME));
mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
Mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
serviceProviderMock.Verify(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
}
@ -75,14 +75,14 @@ namespace NzbDrone.App.Test
[Test]
public void Route_should_call_console_service_when_application_mode_is_console()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var consoleProvider = mocker.GetMock<ConsoleProvider>();
var appServerProvider = mocker.GetMock<ApplicationServer>();
WithStrictMocker();
var consoleProvider = Mocker.GetMock<ConsoleProvider>();
var appServerProvider = Mocker.GetMock<ApplicationServer>();
consoleProvider.Setup(c => c.WaitForClose());
appServerProvider.Setup(c => c.Start());
mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
mocker.Resolve<Router>().Route(ApplicationMode.Console);
Mocker.Resolve<Router>().Route(ApplicationMode.Console);
consoleProvider.Verify(c => c.WaitForClose(), Times.Once());
appServerProvider.Verify(c => c.Start(), Times.Once());
@ -94,15 +94,15 @@ namespace NzbDrone.App.Test
[TestCase(ApplicationMode.Help)]
public void Route_should_call_service_start_when_run_in_service_more(ApplicationMode applicationMode)
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var envMock = mocker.GetMock<EnviromentProvider>();
var serviceProvider = mocker.GetMock<ServiceProvider>();
WithStrictMocker();
var envMock = Mocker.GetMock<EnviromentProvider>();
var serviceProvider = Mocker.GetMock<ServiceProvider>();
envMock.SetupGet(c => c.IsUserInteractive).Returns(false);
serviceProvider.Setup(c => c.Run(It.IsAny<ServiceBase>()));
mocker.Resolve<Router>().Route(applicationMode);
Mocker.Resolve<Router>().Route(applicationMode);
serviceProvider.Verify(c => c.Run(It.IsAny<ServiceBase>()), Times.Once());
}
@ -111,33 +111,33 @@ namespace NzbDrone.App.Test
[Test]
public void show_error_on_install_if_service_already_exist()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var consoleMock = mocker.GetMock<ConsoleProvider>();
var serviceMock = mocker.GetMock<ServiceProvider>();
mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
WithStrictMocker();
var consoleMock = Mocker.GetMock<ConsoleProvider>();
var serviceMock = Mocker.GetMock<ServiceProvider>();
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
Mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void show_error_on_uninstall_if_service_doesnt_exist()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var consoleMock = mocker.GetMock<ConsoleProvider>();
var serviceMock = mocker.GetMock<ServiceProvider>();
mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
WithStrictMocker();
var consoleMock = Mocker.GetMock<ConsoleProvider>();
var serviceMock = Mocker.GetMock<ServiceProvider>();
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
consoleMock.Setup(c => c.PrintServiceDoestExist());
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
Mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
}
}

View File

@ -57,8 +57,6 @@ namespace NzbDrone.Common.Test
const string key = "LaunchBrowser";
const bool value = true;
var mocker = new AutoMoqer();
//Act
var result = Mocker.Resolve<ConfigFileProvider>().GetValueBoolean(key, value);
@ -69,8 +67,6 @@ namespace NzbDrone.Common.Test
[Test]
public void GetLaunchBrowser_Success()
{
var mocker = new AutoMoqer();
//Act
var result = Mocker.Resolve<ConfigFileProvider>().LaunchBrowser;

View File

@ -32,18 +32,18 @@ namespace NzbDrone.Core.Test
[TestCase("nzbmatrix.xml", 2)]
public void parse_feed_xml(string fileName, int warns)
{
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>()
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>()
Mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
var mockIndexer = mocker.Resolve<MockIndexer>();
var mockIndexer = Mocker.Resolve<MockIndexer>();
var parseResults = mockIndexer.FetchRss();
foreach (var episodeParseResult in parseResults)
@ -63,15 +63,15 @@ namespace NzbDrone.Core.Test
[Test]
public void newzbin_parses_languae()
{
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>()
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\newbin_none_english.xml"));
var newzbin = mocker.Resolve<Newzbin>();
var newzbin = Mocker.Resolve<Newzbin>();
var parseResults = newzbin.FetchRss();
foreach (var episodeParseResult in parseResults)
@ -88,22 +88,22 @@ namespace NzbDrone.Core.Test
[Test]
public void newzbin_rss_fetch()
{
var mocker = new AutoMoqer();
mocker.Resolve<HttpProvider>();
Mocker.Resolve<HttpProvider>();
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>()
Mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NewzbinUsername)
.Returns("nzbdrone");
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NewzbinPassword)
.Returns("smartar39865");
var newzbinProvider = mocker.Resolve<Newzbin>();
var newzbinProvider = Mocker.Resolve<Newzbin>();
var parseResults = newzbinProvider.FetchRss();
foreach (var episodeParseResult in parseResults)
@ -125,12 +125,12 @@ namespace NzbDrone.Core.Test
[TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)]
public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality)
{
var mocker = new AutoMoqer();
const string summary = "My fake summary";
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>()
Mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test
.With(c => c.Summary = new TextSyndicationContent(summary))
.Build();
var result = mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
var result = Mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
Assert.IsNotNull(result);
Assert.AreEqual(LanguageType.Finnish, result.Language);
@ -152,12 +152,12 @@ namespace NzbDrone.Core.Test
[TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")]
public void custome_parser_full_parse(string title)
{
var mocker = new AutoMoqer();
const string summary = "My fake summary";
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>()
Mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
@ -166,7 +166,7 @@ namespace NzbDrone.Core.Test
.With(c => c.Summary = new TextSyndicationContent(summary))
.Build();
var result = mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
var result = Mocker.Resolve<CustomParserIndexer>().ParseFeed(fakeRssItem);
Assert.IsNotNull(result);
Assert.AreEqual(LanguageType.Finnish, result.Language);
@ -176,15 +176,15 @@ namespace NzbDrone.Core.Test
[Test]
public void downloadFeed()
{
var mocker = new AutoMoqer();
mocker.SetConstant(new HttpProvider());
Mocker.SetConstant(new HttpProvider());
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
mocker.GetMock<IndexerProvider>()
Mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
mocker.Resolve<TestUrlIndexer>().FetchRss();
Mocker.Resolve<TestUrlIndexer>().FetchRss();
ExceptionVerification.IgnoreWarns();
}
@ -194,19 +194,19 @@ namespace NzbDrone.Core.Test
[TestCase("In plain Sight", 1, 4)]
public void nzbsorg_search_returns_valid_results(string title, int season, int episode)
{
var mocker = new AutoMoqer();
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbsOrgUId)
.Returns("43516");
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbsOrgHash)
.Returns("bc8edb4cc49d4ae440775adec5ac001f");
mocker.Resolve<HttpProvider>();
Mocker.Resolve<HttpProvider>();
var result = mocker.Resolve<NzbsOrg>().FetchEpisode(title, season, episode);
var result = Mocker.Resolve<NzbsOrg>().FetchEpisode(title, season, episode);
ExceptionVerification.MarkInconclusive(typeof(WebException));
@ -221,19 +221,19 @@ namespace NzbDrone.Core.Test
[TestCase("In plain Sight", 1, 11, Ignore = true)]
public void newzbin_search_returns_valid_results(string title, int season, int episode)
{
var mocker = new AutoMoqer();
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NewzbinUsername)
.Returns("nzbdrone");
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NewzbinPassword)
.Returns("smartar39865");
mocker.Resolve<HttpProvider>();
Mocker.Resolve<HttpProvider>();
var result = mocker.Resolve<Newzbin>().FetchEpisode(title, season, episode);
var result = Mocker.Resolve<Newzbin>().FetchEpisode(title, season, episode);
ExceptionVerification.MarkInconclusive(typeof(WebException));
ExceptionVerification.IgnoreWarns();
@ -248,19 +248,19 @@ namespace NzbDrone.Core.Test
[Test]
public void nzbmatrix_search_returns_valid_results()
{
var mocker = new AutoMoqer();
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixUsername)
.Returns("");
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixApiKey)
.Returns("");
mocker.Resolve<HttpProvider>();
Mocker.Resolve<HttpProvider>();
var result = mocker.Resolve<NzbMatrix>().FetchEpisode("Simpsons", 21, 23);
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Simpsons", 21, 23);
ExceptionVerification.MarkInconclusive(typeof(WebException));
@ -274,19 +274,19 @@ namespace NzbDrone.Core.Test
[Test]
public void nzbmatrix_multi_word_search_returns_valid_results()
{
var mocker = new AutoMoqer();
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixUsername)
.Returns("");
mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixApiKey)
.Returns("");
mocker.Resolve<HttpProvider>();
Mocker.Resolve<HttpProvider>();
var result = mocker.Resolve<NzbMatrix>().FetchEpisode("Blue Bloods", 1, 19);
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Blue Bloods", 1, 19);
ExceptionVerification.MarkInconclusive(typeof(WebException));
@ -311,14 +311,14 @@ namespace NzbDrone.Core.Test
public void size_newzbin()
{
//Setup
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>()
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml"));
//Act
var parseResults = mocker.Resolve<Newzbin>().FetchRss();
var parseResults = Mocker.Resolve<Newzbin>().FetchRss();
parseResults.Should().HaveCount(1);
parseResults[0].Size.Should().Be(1295620506);
@ -328,14 +328,14 @@ namespace NzbDrone.Core.Test
public void size_nzbmatrix()
{
//Setup
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>()
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbmatrix.xml"));
//Act
var parseResults = mocker.Resolve<NzbMatrix>().FetchRss();
var parseResults = Mocker.Resolve<NzbMatrix>().FetchRss();
parseResults.Should().HaveCount(1);
parseResults[0].Size.Should().Be(1331439862);
@ -345,14 +345,14 @@ namespace NzbDrone.Core.Test
public void size_nzbsorg()
{
//Setup
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>()
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsorg.xml"));
//Act
var parseResults = mocker.Resolve<NzbsOrg>().FetchRss();
var parseResults = Mocker.Resolve<NzbsOrg>().FetchRss();
parseResults.Should().HaveCount(1);
parseResults[0].Size.Should().Be(1793148846);
@ -362,14 +362,14 @@ namespace NzbDrone.Core.Test
public void size_nzbsrus()
{
//Setup
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>()
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsrus.xml"));
//Act
var parseResults = mocker.Resolve<NzbsRUs>().FetchRss();
var parseResults = Mocker.Resolve<NzbsRUs>().FetchRss();
parseResults.Should().HaveCount(1);
parseResults[0].Size.Should().Be(1793148846);

View File

@ -8,12 +8,13 @@ using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
public class BacklogSearchJobTest
public class BacklogSearchJobTest : CoreTest
{
[Test]
public void no_missing_epsiodes_should_not_trigger_any_search()
@ -23,19 +24,19 @@ namespace NzbDrone.Core.Test.JobTests
var episodes = new List<Episode>();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
//Act
mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
//Assert
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Times.Never());
mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Times.Never());
}
@ -47,22 +48,22 @@ namespace NzbDrone.Core.Test.JobTests
var episodes = Builder<Episode>.CreateListOfSize(1).Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
mocker.GetMock<EpisodeSearchJob>()
Mocker.GetMock<EpisodeSearchJob>()
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
//Act
mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
//Assert
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Times.Never());
mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Times.Once());
}
@ -74,22 +75,22 @@ namespace NzbDrone.Core.Test.JobTests
var episodes = Builder<Episode>.CreateListOfSize(5).Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
mocker.GetMock<EpisodeSearchJob>()
Mocker.GetMock<EpisodeSearchJob>()
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
//Act
mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
//Assert
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Times.Never());
mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Times.Exactly(episodes.Count));
}
@ -105,25 +106,25 @@ namespace NzbDrone.Core.Test.JobTests
.With(e => e.SeasonNumber = 1)
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
mocker.GetMock<EpisodeSearchJob>()
Mocker.GetMock<EpisodeSearchJob>()
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
//Act
mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
//Assert
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Times.Never());
mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Times.Exactly(episodes.Count));
}
@ -139,25 +140,25 @@ namespace NzbDrone.Core.Test.JobTests
.With(e => e.SeasonNumber = 1)
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
mocker.GetMock<SeasonSearchJob>()
Mocker.GetMock<SeasonSearchJob>()
.Setup(s => s.Start(notification, It.IsAny<int>(), It.IsAny<int>())).Verifiable();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
//Act
mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
//Assert
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Times.Once());
mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Times.Never());
}
@ -173,28 +174,28 @@ namespace NzbDrone.Core.Test.JobTests
.With(e => e.SeasonNumber = 1)
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
mocker.GetMock<SeasonSearchJob>()
Mocker.GetMock<SeasonSearchJob>()
.Setup(s => s.Start(notification, It.IsAny<int>(), It.IsAny<int>())).Verifiable();
mocker.GetMock<EpisodeSearchJob>()
Mocker.GetMock<EpisodeSearchJob>()
.Setup(s => s.Start(notification, It.IsAny<int>(), 0)).Verifiable();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
//Act
mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
Mocker.Resolve<BacklogSearchJob>().Start(notification, 0, 0);
//Assert
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), It.IsAny<int>()),
Times.Once());
mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Mocker.GetMock<EpisodeSearchJob>().Verify(c => c.Start(notification, It.IsAny<int>(), 0),
Times.Exactly(5));
}
}

View File

@ -27,22 +27,22 @@ namespace NzbDrone.Core.Test.JobTests
.With(s => s.SeriesId = 12)
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.GetSeries(series.SeriesId))
.Returns(series);
mocker.GetMock<DiskScanProvider>()
Mocker.GetMock<DiskScanProvider>()
.Setup(p => p.Scan(series))
.Returns(new List<EpisodeFile>());
//Act
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), series.SeriesId, 0);
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), series.SeriesId, 0);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
@ -55,24 +55,24 @@ namespace NzbDrone.Core.Test.JobTests
.TheNext(1).With(s => s.SeriesId = 15)
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.GetAllSeries())
.Returns(series);
mocker.GetMock<DiskScanProvider>()
Mocker.GetMock<DiskScanProvider>()
.Setup(s => s.Scan(series[0]))
.Returns(new List<EpisodeFile>());
mocker.GetMock<DiskScanProvider>()
Mocker.GetMock<DiskScanProvider>()
.Setup(s => s.Scan(series[1]))
.Returns(new List<EpisodeFile>());
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
@ -83,24 +83,24 @@ namespace NzbDrone.Core.Test.JobTests
.TheNext(1).With(s => s.SeriesId = 15)
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.GetAllSeries())
.Returns(series);
mocker.GetMock<DiskScanProvider>()
Mocker.GetMock<DiskScanProvider>()
.Setup(s => s.Scan(series[0]))
.Throws(new InvalidOperationException("Bad Job"));
mocker.GetMock<DiskScanProvider>()
Mocker.GetMock<DiskScanProvider>()
.Setup(s => s.Scan(series[1]))
.Throws(new InvalidOperationException("Bad Job"));
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
ExceptionVerification.ExcpectedErrors(2);
}
@ -112,26 +112,26 @@ namespace NzbDrone.Core.Test.JobTests
.TheNext(1).With(s => s.SeriesId = 15)
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.GetAllSeries())
.Returns(series);
mocker.GetMock<DiskScanProvider>()
Mocker.GetMock<DiskScanProvider>()
.Setup(s => s.Scan(series[0]))
.Returns(new List<EpisodeFile>());
mocker.GetMock<DiskScanProvider>()
Mocker.GetMock<DiskScanProvider>()
.Setup(s => s.Scan(series[1]))
.Returns(new List<EpisodeFile>());
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0, 0);
mocker.VerifyAllMocks();
mocker.GetMock<DiskScanProvider>().Verify(s => s.Scan(It.IsAny<Series>()), Times.Exactly(2));
Mocker.VerifyAllMocks();
Mocker.GetMock<DiskScanProvider>().Verify(s => s.Scan(It.IsAny<Series>()), Times.Exactly(2));
}
}

View File

@ -31,53 +31,53 @@ namespace NzbDrone.Core.Test.JobTests
var notification = new ProgressNotification("Test");
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.GetAllSeries())
.Returns(series);
mocker.GetMock<DiskScanJob>()
Mocker.GetMock<DiskScanJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Callback(() => series[0].LastDiskSync = DateTime.Now);
mocker.GetMock<DiskScanJob>()
Mocker.GetMock<DiskScanJob>()
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
.Callback(() => series[1].LastDiskSync = DateTime.Now);
mocker.GetMock<BannerDownloadJob>()
Mocker.GetMock<BannerDownloadJob>()
.Setup(j => j.Start(notification, It.IsAny<int>(), 0));
mocker.GetMock<UpdateInfoJob>()
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Callback(() => series[0].LastInfoSync = DateTime.Now);
mocker.GetMock<UpdateInfoJob>()
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
.Callback(() => series[1].LastInfoSync = DateTime.Now);
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]);
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(s => s.GetSeries(series[1].SeriesId)).Returns(series[1]);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
//Act
mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
}
@ -96,43 +96,43 @@ namespace NzbDrone.Core.Test.JobTests
var notification = new ProgressNotification("Test");
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.GetAllSeries())
.Returns(series);
mocker.GetMock<UpdateInfoJob>()
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Callback(() => series[0].LastInfoSync = DateTime.Now);
mocker.GetMock<UpdateInfoJob>()
Mocker.GetMock<UpdateInfoJob>()
.Setup(j => j.Start(notification, series[1].SeriesId, 0))
.Throws(new InvalidOperationException());
mocker.GetMock<DiskScanJob>()
Mocker.GetMock<DiskScanJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0))
.Callback(() => series[0].LastDiskSync = DateTime.Now);
mocker.GetMock<BannerDownloadJob>()
Mocker.GetMock<BannerDownloadJob>()
.Setup(j => j.Start(notification, series[0].SeriesId, 0));
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
//Act
mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
Mocker.Resolve<ImportNewSeriesJob>().Start(notification, 0, 0);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<UpdateInfoJob>().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once());
mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
Mocker.GetMock<DiskScanJob>().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once());
ExceptionVerification.ExcpectedErrors(1);
@ -145,19 +145,19 @@ namespace NzbDrone.Core.Test.JobTests
{
int seriesId = 12;
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<MediaFileProvider>()
WithStrictMocker();
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.GetSeriesFiles(seriesId))
.Returns(new List<EpisodeFile>());
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetSeasons(seriesId))
.Returns(new List<int> { 0, 1, 2, 3, 4 });
mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
}
[Test]
@ -172,19 +172,19 @@ namespace NzbDrone.Core.Test.JobTests
episodesFiles[0].SeasonNumber = 0;
episodesFiles[1].SeasonNumber = 1;
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.GetSeriesFiles(seriesId))
.Returns(episodesFiles);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetSeasons(seriesId))
.Returns(new List<int> { 0, 1, 2 });
mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
}
[Test]
@ -198,21 +198,21 @@ namespace NzbDrone.Core.Test.JobTests
episodesFiles[0].SeasonNumber = 1;
var mocker = new AutoMoqer();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.GetSeriesFiles(seriesId))
.Returns(episodesFiles);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetSeasons(seriesId))
.Returns(new List<int> { 0, 1, 2 });
mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 0, true), Times.Once());
mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 1, true), Times.Never());
mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 0, true), Times.Once());
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 1, true), Times.Never());
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
}
}

View File

@ -4,12 +4,13 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
public class SearchJobTest
public class SearchJobTest:CoreTest
{
[TestCase(0)]
[TestCase(-1)]
@ -17,8 +18,8 @@ namespace NzbDrone.Core.Test.JobTests
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void start_target_id_less_than_0_throws_exception(int target)
{
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.Resolve<EpisodeSearchJob>().Start(new ProgressNotification("Test"), target, 0);
WithStrictMocker();
Mocker.Resolve<EpisodeSearchJob>().Start(new ProgressNotification("Test"), target, 0);
}
[TestCase(0)]
@ -27,8 +28,8 @@ namespace NzbDrone.Core.Test.JobTests
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void start_secondary_target_id_less_than_0_throws_exception(int target)
{
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.Resolve<SeasonSearchJob>().Start(new ProgressNotification("Test"), 0, target);
WithStrictMocker();
Mocker.Resolve<SeasonSearchJob>().Start(new ProgressNotification("Test"), 0, target);
}
}
}

View File

@ -19,25 +19,25 @@ namespace NzbDrone.Core.Test.JobTests
{
var seasons = new List<int> { 1, 2, 3, 4, 5 };
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var notification = new ProgressNotification("Series Search");
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetSeasons(1)).Returns(seasons);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
mocker.GetMock<SeasonSearchJob>()
Mocker.GetMock<SeasonSearchJob>()
.Setup(c => c.Start(notification, 1, It.IsAny<int>())).Verifiable();
//Act
mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
Mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
//Assert
mocker.VerifyAllMocks();
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
Mocker.VerifyAllMocks();
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
Times.Exactly(seasons.Count));
}
@ -46,19 +46,19 @@ namespace NzbDrone.Core.Test.JobTests
{
var seasons = new List<int>();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var notification = new ProgressNotification("Series Search");
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetSeasons(1)).Returns(seasons);
//Act
mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
Mocker.Resolve<SeriesSearchJob>().Start(notification, 1, 0);
//Assert
mocker.VerifyAllMocks();
mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
Mocker.VerifyAllMocks();
Mocker.GetMock<SeasonSearchJob>().Verify(c => c.Start(notification, 1, It.IsAny<int>()),
Times.Never());
}

View File

@ -23,15 +23,15 @@ namespace NzbDrone.Core.Test.ProviderTests
const string key = "MY_KEY";
const string value = "MY_VALUE";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
mocker.Resolve<ConfigProvider>().SetValue(key, value);
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
//Assert
mocker.Resolve<ConfigProvider>().GetValue(key, "").Should().Be(value);
Mocker.Resolve<ConfigProvider>().GetValue(key, "").Should().Be(value);
}
[Test]
@ -40,15 +40,15 @@ namespace NzbDrone.Core.Test.ProviderTests
const string key = "MY_KEY";
const string value = "MY_VALUE";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(new Config { Key = key, Value = value });
db.Insert(new Config { Key = "Other Key", Value = "OtherValue" });
//Act
var result = mocker.Resolve<ConfigProvider>().GetValue(key, "");
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(value);
@ -61,13 +61,13 @@ namespace NzbDrone.Core.Test.ProviderTests
const string key = "MY_KEY";
const string value = "MY_VALUE";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
var result = mocker.Resolve<ConfigProvider>().GetValue(key, value);
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, value);
//Assert
result.Should().Be(value);
@ -80,15 +80,15 @@ namespace NzbDrone.Core.Test.ProviderTests
const string originalValue = "OLD_VALUE";
const string newValue = "NEW_VALUE";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(new Config { Key = key, Value = originalValue });
//Act
mocker.Resolve<ConfigProvider>().SetValue(key, newValue);
var result = mocker.Resolve<ConfigProvider>().GetValue(key, "");
Mocker.Resolve<ConfigProvider>().SetValue(key, newValue);
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(newValue);
@ -102,14 +102,14 @@ namespace NzbDrone.Core.Test.ProviderTests
const string value = "OLD_VALUE";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
mocker.Resolve<ConfigProvider>().SetValue(key, value);
mocker.Resolve<ConfigProvider>().SetValue(key, value);
var result = mocker.Resolve<ConfigProvider>().GetValue(key, "");
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(value);
@ -121,11 +121,11 @@ namespace NzbDrone.Core.Test.ProviderTests
public void config_properties_should_write_and_read_using_same_key()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
var configProvider = mocker.Resolve<ConfigProvider>();
var configProvider = Mocker.Resolve<ConfigProvider>();
var allProperties = typeof(ConfigProvider).GetProperties();

View File

@ -21,11 +21,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
public void FreeDiskSpace()
{
//Setup
var mocker = new AutoMoqer();
//Act
var di = new DirectoryInfo(Directory.GetCurrentDirectory());
var result = mocker.Resolve<DiskProvider>().FreeDiskSpace(di);
var result = Mocker.Resolve<DiskProvider>().FreeDiskSpace(di);
//Asert
//Checks to ensure that the free space on the first is greater than 0 (It should be in 99.99999999999999% of cases... I hope)

View File

@ -24,74 +24,74 @@ namespace NzbDrone.Core.Test.ProviderTests
public void scan_series_should_update_the_last_scan_date()
{
var mocker = new AutoMoqer();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(c => c.UpdateSeries(It.Is<Series>(s => s.LastDiskSync != null))).Verifiable();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetEpisodeBySeries(It.IsAny<long>()))
.Returns(new List<Episode> { new Episode() });
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetSeriesFiles(It.IsAny<int>()))
.Returns(new List<EpisodeFile>());
mocker.Resolve<DiskScanProvider>().Scan(new Series());
Mocker.Resolve<DiskScanProvider>().Scan(new Series());
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void cleanup_should_skip_existing_files()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var episodes = Builder<EpisodeFile>.CreateListOfSize(10).Build();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.FileExists(It.IsAny<String>()))
.Returns(true);
//Act
mocker.Resolve<DiskScanProvider>().CleanUp(episodes);
Mocker.Resolve<DiskScanProvider>().CleanUp(episodes);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void cleanup_should_delete_none_existing_files()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var episodes = Builder<EpisodeFile>.CreateListOfSize(10).Build();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.FileExists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByFileId(It.IsAny<int>()))
.Returns(new List<Episode>());
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.Delete(It.IsAny<int>()));
//Act
mocker.Resolve<DiskScanProvider>().CleanUp(episodes);
Mocker.Resolve<DiskScanProvider>().CleanUp(episodes);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Verify(e => e.GetEpisodesByFileId(It.IsAny<int>()), Times.Exactly(10));
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Verify(e => e.Delete(It.IsAny<int>()), Times.Exactly(10));
}
@ -99,40 +99,40 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void cleanup_should_delete_none_existing_files_remove_links_to_episodes()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var episodes = Builder<EpisodeFile>.CreateListOfSize(10).Build();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.FileExists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByFileId(It.IsAny<int>()))
.Returns(new List<Episode> { new Episode { EpisodeFileId = 10 }, new Episode { EpisodeFileId = 10 } });
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.UpdateEpisode(It.IsAny<Episode>()));
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.Delete(It.IsAny<int>()));
//Act
mocker.Resolve<DiskScanProvider>().CleanUp(episodes);
Mocker.Resolve<DiskScanProvider>().CleanUp(episodes);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Verify(e => e.GetEpisodesByFileId(It.IsAny<int>()), Times.Exactly(10));
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Verify(e => e.UpdateEpisode(It.Is<Episode>(g=>g.EpisodeFileId == 0)), Times.Exactly(20));
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Verify(e => e.Delete(It.IsAny<int>()), Times.Exactly(10));
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Verify(e => e.Delete(It.IsAny<int>()), Times.Exactly(10));
}
@ -141,29 +141,29 @@ namespace NzbDrone.Core.Test.ProviderTests
public void scan_series_should_log_warning_if_path_doesnt_exist_on_disk()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var series = Builder<Series>.CreateNew()
.With(s => s.Path = @"C:\Test\TV\SeriesName\")
.Build();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.DeleteOrphaned())
.Returns(0);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.RepairLinks())
.Returns(0);
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(c => c.FolderExists(series.Path))
.Returns(false);
//Act
mocker.Resolve<DiskScanProvider>().Scan(series, series.Path);
Mocker.Resolve<DiskScanProvider>().Scan(series, series.Path);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
ExceptionVerification.ExcpectedWarns(1);
}

View File

@ -29,23 +29,23 @@ namespace NzbDrone.Core.Test.ProviderTests
var fakeEpisode = Builder<Episode>.CreateNew().Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(newFile)).Returns(12345).Verifiable();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(new List<Episode> { fakeEpisode });
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
//Assert
VerifyFileImport(result, mocker, fakeEpisode, 12345);
VerifyFileImport(result, Mocker, fakeEpisode, 12345);
}
@ -65,21 +65,21 @@ namespace NzbDrone.Core.Test.ProviderTests
.And(g => g.Proper = currentFileProper).Build()
).Build();
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(newFile)).Returns(12345).Verifiable();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(new List<Episode> { fakeEpisode });
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, newFile);
//Assert
VerifyFileImport(result, mocker, fakeEpisode, size);
VerifyFileImport(result, Mocker, fakeEpisode, size);
}
[TestCase("WEEDS.S03E01.DUAL.DVD.XviD.AC3.-HELLYWOOD.avi")]
@ -96,23 +96,23 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(new List<Episode> { fakeEpisode });
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, mocker);
VerifySkipImport(result, Mocker);
}
[Test]
@ -124,19 +124,19 @@ namespace NzbDrone.Core.Test.ProviderTests
var fakeSeries = Builder<Series>.CreateNew().Build();
var mocker = new AutoMoqer();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>())).Returns(false);
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, mocker);
VerifySkipImport(result, Mocker);
ExceptionVerification.ExcpectedWarns(2);
}
@ -149,19 +149,19 @@ namespace NzbDrone.Core.Test.ProviderTests
var fakeSeries = Builder<Series>.CreateNew().Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>())).Returns(false);
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, mocker);
VerifySkipImport(result, Mocker);
}
[Test]
@ -171,16 +171,16 @@ namespace NzbDrone.Core.Test.ProviderTests
var fakeSeries = Builder<Series>.CreateNew().Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<MediaFileProvider>()
WithStrictMocker();
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(true);
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, mocker);
VerifySkipImport(result, Mocker);
}
[Test]
@ -193,24 +193,24 @@ namespace NzbDrone.Core.Test.ProviderTests
var fakeSeries = Builder<Series>.CreateNew().Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<DiskProvider>(MockBehavior.Strict)
Mocker.GetMock<DiskProvider>(MockBehavior.Strict)
.Setup(e => e.GetSize(fileName)).Returns(90000000000);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false))
.Returns(new List<Episode>());
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, mocker);
VerifySkipImport(result, Mocker);
}
[TestCase("WEEDS.S03E01.DUAL.DVD.XviD.AC3.-HELLYWOOD.avi")]
@ -227,24 +227,24 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(new List<Episode> { fakeEpisode });
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, mocker, fakeEpisode, 12345);
mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Once());
VerifyFileImport(result, Mocker, fakeEpisode, 12345);
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Once());
}
[TestCase("WEEDS.S03E01.DUAL.hdtv.XviD.AC3.-HELLYWOOD.avi")]
@ -263,24 +263,24 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(fakeEpisodes);
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, mocker, fakeEpisodes[0], 12345);
mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Once());
VerifyFileImport(result, Mocker, fakeEpisodes[0], 12345);
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Once());
}
[TestCase("WEEDS.S03E01.DUAL.DVD.XviD.AC3.-HELLYWOOD.avi")]
@ -298,23 +298,23 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(fakeEpisodes);
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifySkipImport(result, mocker);
VerifySkipImport(result, Mocker);
}
[Test]
@ -339,24 +339,24 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(new List<Episode> { fakeEpisode1, fakeEpisode2 });
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, mocker, fakeEpisode1, 12345);
mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Exactly(2));
VerifyFileImport(result, Mocker, fakeEpisode1, 12345);
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Exactly(2));
}
[Test]
@ -373,48 +373,48 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(p => p.Exists(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(new List<Episode> { fakeEpisode});
//Act
var result = mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(fakeSeries, fileName);
//Assert
VerifyFileImport(result, mocker, fakeEpisode, 12345);
mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Never());
VerifyFileImport(result, Mocker, fakeEpisode, 12345);
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Never());
}
private static void VerifyFileImport(EpisodeFile result, AutoMoqer mocker, Episode fakeEpisode, int size)
private static void VerifyFileImport(EpisodeFile result, AutoMoqer Mocker, Episode fakeEpisode, int size)
{
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
result.Should().NotBeNull();
result.SeriesId.Should().Be(fakeEpisode.SeriesId);
result.Size.Should().Be(size);
result.DateAdded.Should().HaveDay(DateTime.Now.Day);
mocker.GetMock<MediaFileProvider>().Verify(p => p.Add(It.IsAny<EpisodeFile>()), Times.Once());
Mocker.GetMock<MediaFileProvider>().Verify(p => p.Add(It.IsAny<EpisodeFile>()), Times.Once());
//Get the count of episodes linked
var count = mocker.GetMock<EpisodeProvider>().Object.GetEpisodesByParseResult(null, false).Count;
var count = Mocker.GetMock<EpisodeProvider>().Object.GetEpisodesByParseResult(null, false).Count;
mocker.GetMock<EpisodeProvider>().Verify(p => p.UpdateEpisode(It.Is<Episode>(e => e.EpisodeFileId == result.EpisodeFileId)), Times.Exactly(count));
Mocker.GetMock<EpisodeProvider>().Verify(p => p.UpdateEpisode(It.Is<Episode>(e => e.EpisodeFileId == result.EpisodeFileId)), Times.Exactly(count));
}
private static void VerifySkipImport(EpisodeFile result, AutoMoqer mocker)
private static void VerifySkipImport(EpisodeFile result, AutoMoqer Mocker)
{
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
result.Should().BeNull();
mocker.GetMock<MediaFileProvider>().Verify(p => p.Add(It.IsAny<EpisodeFile>()), Times.Never());
mocker.GetMock<EpisodeProvider>().Verify(p => p.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Never());
Mocker.GetMock<MediaFileProvider>().Verify(p => p.Add(It.IsAny<EpisodeFile>()), Times.Never());
Mocker.GetMock<EpisodeProvider>().Verify(p => p.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Never());
}
}
}

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var parseResult = Builder<EpisodeParseResult>.CreateNew()
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
.Build();
@ -33,38 +33,38 @@ namespace NzbDrone.Core.Test.ProviderTests
const string sabTitle = "My fake sab title";
mocker.GetMock<SabProvider>()
Mocker.GetMock<SabProvider>()
.Setup(s => s.IsInQueue(It.IsAny<String>()))
.Returns(false);
mocker.GetMock<SabProvider>()
Mocker.GetMock<SabProvider>()
.Setup(s => s.AddByUrl(parseResult.NzbUrl, sabTitle))
.Returns(true);
mocker.GetMock<SabProvider>()
Mocker.GetMock<SabProvider>()
.Setup(s => s.GetSabTitle(parseResult))
.Returns(sabTitle);
mocker.GetMock<HistoryProvider>()
Mocker.GetMock<HistoryProvider>()
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 12 && h.SeriesId == 5)));
mocker.GetMock<HistoryProvider>()
Mocker.GetMock<HistoryProvider>()
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 99 && h.SeriesId == 5)));
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(episodes);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.MarkEpisodeAsFetched(12));
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.MarkEpisodeAsFetched(99));
mocker.GetMock<ExternalNotificationProvider>()
Mocker.GetMock<ExternalNotificationProvider>()
.Setup(c => c.OnGrab(It.IsAny<string>()));
mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
Mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
}
}

View File

@ -42,16 +42,16 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.TvDbEpisodeId = tvDbSeries.Episodes.First().Id)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(fakeSeries);
db.Insert(fakeEpisode);
//Act
mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert
var result = db.Fetch<Episode>();
@ -82,16 +82,16 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.TvDbEpisodeId = 0)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(fakeSeries);
db.Insert(fakeEpisode);
//Act
mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert
var result = db.Fetch<Episode>();
@ -122,16 +122,16 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.TvDbEpisodeId = null)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(fakeSeries);
db.Insert(fakeEpisode);
//Act
mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert
var result = db.Fetch<Episode>();
@ -164,16 +164,16 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.TvDbEpisodeId = 300)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(fakeSeries);
db.Insert(fakeEpisode);
//Act
mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert
var result = db.Fetch<Episode>();
@ -219,10 +219,10 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.TvDbEpisodeId = 300)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(fakeSeries);
db.Insert(fakeEpisode);
@ -230,7 +230,7 @@ namespace NzbDrone.Core.Test.ProviderTests
db.Insert(otherFakeEpisode);
//Act
mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert
var result = db.Fetch<Episode>();

View File

@ -20,17 +20,17 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_true()
{
//Setup
var mocker = new AutoMoqer();
var header = "NzbDrone Test";
var message = "Test Message!";
var address = "localhost";
var fakeUdp = mocker.GetMock<UdpProvider>();
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);
var result = Mocker.Resolve<EventClientProvider>().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address);
//Assert
Assert.AreEqual(true, result);
@ -40,17 +40,17 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_false()
{
//Setup
var mocker = new AutoMoqer();
var header = "NzbDrone Test";
var message = "Test Message!";
var address = "localhost";
var fakeUdp = mocker.GetMock<UdpProvider>();
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);
var result = Mocker.Resolve<EventClientProvider>().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address);
//Assert
Assert.AreEqual(false, result);
@ -60,17 +60,17 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendAction_Update_true()
{
//Setup
var mocker = new AutoMoqer();
var path = @"C:\Test\TV\30 Rock";
var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", path);
var address = "localhost";
var fakeUdp = mocker.GetMock<UdpProvider>();
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);
var result = Mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
//Assert
Assert.AreEqual(true, result);
@ -80,17 +80,17 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendAction_Update_false()
{
//Setup
var mocker = new AutoMoqer();
var path = @"C:\Test\TV\30 Rock";
var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", path);
var address = "localhost";
var fakeUdp = mocker.GetMock<UdpProvider>();
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);
var result = Mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
//Assert
Assert.AreEqual(false, result);

View File

@ -23,52 +23,52 @@ namespace NzbDrone.Core.Test.ProviderTests
public void Register_should_add_new_application_to_local_growl_instance()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
mocker.Resolve<GrowlProvider>().Register("localhost", 23053, "");
Mocker.Resolve<GrowlProvider>().Register("localhost", 23053, "");
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void TestNotification_should_send_a_message_to_local_growl_instance()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
mocker.Resolve<GrowlProvider>().TestNotification("localhost", 23053, "");
Mocker.Resolve<GrowlProvider>().TestNotification("localhost", 23053, "");
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void OnGrab_should_send_a_message_to_local_growl_instance()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
mocker.Resolve<GrowlProvider>().SendNotification("Episode Grabbed", "Series Title - 1x05 - Episode Title", "GRAB", "localhost", 23053, "");
Mocker.Resolve<GrowlProvider>().SendNotification("Episode Grabbed", "Series Title - 1x05 - Episode Title", "GRAB", "localhost", 23053, "");
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void OnDownload_should_send_a_message_to_local_growl_instance()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
mocker.Resolve<GrowlProvider>().SendNotification("Episode Downloaded", "Series Title - 1x05 - Episode Title", "DOWNLOAD", "localhost", 23053, "");
Mocker.Resolve<GrowlProvider>().SendNotification("Episode Downloaded", "Series Title - 1x05 - Episode Title", "DOWNLOAD", "localhost", 23053, "");
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
}
}

View File

@ -23,14 +23,14 @@ namespace NzbDrone.Core.Test.ProviderTests
//Setup
var historyItem = Builder<History>.CreateListOfSize(10).Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(historyItem);
//Act
var result = mocker.Resolve<HistoryProvider>().AllItems();
var result = Mocker.Resolve<HistoryProvider>().AllItems();
//Assert
result.Should().HaveSameCount(historyItem);
@ -47,9 +47,9 @@ namespace NzbDrone.Core.Test.ProviderTests
var historyItems = Builder<History>.CreateListOfSize(10).TheFirst(5).With(h => h.SeriesId = seriesOne.SeriesId).TheLast(5).With(h => h.SeriesId = seriesTwo.SeriesId).Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(historyItems);
db.InsertMany(episodes);
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.ProviderTests
db.Insert(seriesTwo);
//Act
var result = mocker.Resolve<HistoryProvider>().AllItemsWithRelationships();
var result = Mocker.Resolve<HistoryProvider>().AllItemsWithRelationships();
//Assert
result.Should().HaveSameCount(historyItems);
@ -75,16 +75,16 @@ namespace NzbDrone.Core.Test.ProviderTests
//Setup
var historyItem = Builder<History>.CreateListOfSize(10).Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(historyItem);
//Act
db.Fetch<History>().Should().HaveCount(10);
mocker.Resolve<HistoryProvider>().Purge();
Mocker.Resolve<HistoryProvider>().Purge();
//Assert
db.Fetch<History>().Should().HaveCount(0);
@ -99,16 +99,16 @@ namespace NzbDrone.Core.Test.ProviderTests
.TheNext(20).With(c => c.Date = DateTime.Now.AddDays(-31))
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(historyItem);
//Act
db.Fetch<History>().Should().HaveCount(30);
mocker.Resolve<HistoryProvider>().Trim();
Mocker.Resolve<HistoryProvider>().Trim();
//Assert
var result = db.Fetch<History>();
@ -120,12 +120,12 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetBestQualityInHistory_no_result()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
var result = mocker.Resolve<HistoryProvider>().GetBestQualityInHistory(12);
var result = Mocker.Resolve<HistoryProvider>().GetBestQualityInHistory(12);
//Assert
Assert.IsNull(result);
@ -134,17 +134,17 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetBestQualityInHistory_single_result()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var db = TestDbHelper.GetEmptyDatabase();
var history = Builder<History>.CreateNew()
.With(h => h.Quality = QualityTypes.Bluray720p).Build();
db.Insert(history);
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
var result = mocker.Resolve<HistoryProvider>().GetBestQualityInHistory(history.EpisodeId);
var result = Mocker.Resolve<HistoryProvider>().GetBestQualityInHistory(history.EpisodeId);
//Assert
result.Should().NotBeNull();
@ -154,10 +154,10 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void add_item()
{
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
var episode = Builder<Episode>.CreateNew().Build();
@ -176,7 +176,7 @@ namespace NzbDrone.Core.Test.ProviderTests
};
//Act
mocker.Resolve<HistoryProvider>().Add(history);
Mocker.Resolve<HistoryProvider>().Add(history);
//Assert
var storedHistory = db.Fetch<History>();

View File

@ -23,13 +23,13 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void Init_indexer_test()
{
var mocker = new AutoMoqer();
mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
var indexerProvider = mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { mocker.Resolve<MockIndexer>() });
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
var settings = indexerProvider.GetSettings(typeof(MockIndexer));
settings.Enable = true;
indexerProvider.SaveSettings(settings);
@ -45,13 +45,13 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void Init_indexer_with_disabled_job()
{
var mocker = new AutoMoqer();
mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
var indexerProvider = mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { mocker.Resolve<MockIndexer>() });
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
var settings = indexerProvider.GetSettings(typeof(MockIndexer));
settings.Enable = false;
indexerProvider.SaveSettings(settings);

View File

@ -72,19 +72,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_single_episode_not_first_or_last_30_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 184572800;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeTrue();
@ -93,19 +93,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_single_episode_not_first_or_last_60_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 368572800;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeTrue();
@ -114,19 +114,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_false_single_episode_not_first_or_last_30_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeFalse();
@ -135,19 +135,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeFalse();
@ -156,19 +156,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultMulti.Series = series30minutes;
parseResultMulti.Size = 184572800;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
//Assert
result.Should().BeTrue();
@ -177,19 +177,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultMulti.Series = series60minutes;
parseResultMulti.Size = 368572800;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
//Assert
result.Should().BeTrue();
@ -198,19 +198,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultMulti.Series = series30minutes;
parseResultMulti.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
//Assert
result.Should().BeFalse();
@ -219,19 +219,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultMulti.Series = series60minutes;
parseResultMulti.Size = 10.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultMulti);
//Assert
result.Should().BeFalse();
@ -240,19 +240,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_single_episode_first_30_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 184572800;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeTrue();
@ -261,19 +261,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_single_episode_first_60_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 368572800;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeTrue();
@ -282,19 +282,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_false_single_episode_first_30_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 1.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeFalse();
@ -303,19 +303,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_false_single_episode_first_60_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 10.Gigabytes();
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeFalse();
@ -324,20 +324,20 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_unlimited_30_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series30minutes;
parseResultSingle.Size = 18457280000;
qualityType.MaxSize = 0;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeTrue();
@ -346,20 +346,20 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsAcceptableSize_true_unlimited_60_minute()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series = series60minutes;
parseResultSingle.Size = 36857280000;
qualityType.MaxSize = 0;
mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
mocker.GetMock<EpisodeProvider>().Setup(
Mocker.GetMock<EpisodeProvider>().Setup(
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(true);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsAcceptableSize(parseResultSingle);
//Assert
result.Should().BeTrue();

View File

@ -86,74 +86,74 @@ namespace NzbDrone.Core.Test.ProviderTests
{
series.Monitored = false;
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns(series);
//Act
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
//Assert
Assert.IsFalse(result);
Assert.AreSame(series, parseResultMulti.Series);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void not_in_db_should_be_skipped()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns<Series>(null);
//Act
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
//Assert
Assert.IsFalse(result);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsMonitored_should_return_true()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns(series);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), true))
.Returns(new List<Episode> { episode });
parseResultSingle.Series.Should().BeNull();
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultSingle);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultSingle);
//Assert
result.Should().BeTrue();
parseResultSingle.Series.Should().Be(series);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsMonitored_ignored_single_episode_should_return_false()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns(series);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), true))
.Returns(new List<Episode> { episode });
@ -161,24 +161,24 @@ namespace NzbDrone.Core.Test.ProviderTests
parseResultSingle.Series.Should().BeNull();
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultSingle);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultSingle);
//Assert
result.Should().BeFalse();
parseResultSingle.Series.Should().Be(series);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsMonitored_multi_some_episodes_ignored_should_return_true()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns(series);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), true))
.Returns(new List<Episode> { episode, episode2 });
@ -187,24 +187,24 @@ namespace NzbDrone.Core.Test.ProviderTests
parseResultMulti.Series.Should().BeNull();
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
//Assert
result.Should().BeTrue();
parseResultMulti.Series.Should().Be(series);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsMonitored_multi_all_episodes_ignored_should_return_false()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns(series);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), true))
.Returns(new List<Episode> { episode, episode2 });
@ -213,25 +213,25 @@ namespace NzbDrone.Core.Test.ProviderTests
parseResultSingle.Series.Should().BeNull();
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
//Assert
result.Should().BeFalse();
parseResultMulti.Series.Should().Be(series);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsMonitored_multi_no_episodes_ignored_should_return_true()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns(series);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), true))
.Returns(new List<Episode> { episode, episode2 });
@ -240,30 +240,30 @@ namespace NzbDrone.Core.Test.ProviderTests
parseResultSingle.Series.Should().BeNull();
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultMulti);
//Assert
result.Should().BeTrue();
parseResultMulti.Series.Should().Be(series);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsMonitored_daily_not_ignored_should_return_true()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<SeriesProvider>()
Mocker.GetMock<SeriesProvider>()
.Setup(p => p.FindSeries(It.IsAny<String>()))
.Returns(series);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), true))
.Returns(new List<Episode> { episode });
episode.Ignored = false;
var result = mocker.Resolve<InventoryProvider>().IsMonitored(parseResultDaily);
var result = Mocker.Resolve<InventoryProvider>().IsMonitored(parseResultDaily);
//Assert
result.Should().BeTrue();

View File

@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.ProviderTests
private Series series;
[SetUp]
public new void Setup()
public void Setup()
{
parseResultMulti = new EpisodeParseResult
{
@ -108,145 +108,145 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void IsQualityNeeded_report_not_in_quality_profile_should_be_skipped()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultMulti.Series.QualityProfile = sdProfile;
parseResultMulti.Quality = new Quality(QualityTypes.HDTV, true);
//Act
bool result = mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultMulti);
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultMulti);
//Assert
Assert.IsFalse(result);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsQualityNeeded_file_already_at_cut_off_should_be_skipped()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultMulti.Series.QualityProfile = hdProfile;
parseResultMulti.Quality = new Quality(QualityTypes.HDTV, true);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(parseResultMulti, true))
.Returns(new List<Episode> { episode, episode2 });
mocker.GetMock<QualityTypeProvider>()
Mocker.GetMock<QualityTypeProvider>()
.Setup(s => s.Get(It.IsAny<int>()))
.Returns(new QualityType { MaxSize = 100, MinSize = 0 });
episode.EpisodeFile.Quality = QualityTypes.Bluray720p;
//Act
bool result = mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultMulti);
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultMulti);
//Assert
Assert.IsFalse(result);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsQualityNeeded_file_in_history_should_be_skipped()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series.QualityProfile = sdProfile;
parseResultSingle.Quality.QualityType = QualityTypes.DVD;
mocker.GetMock<HistoryProvider>()
Mocker.GetMock<HistoryProvider>()
.Setup(p => p.GetBestQualityInHistory(episode.EpisodeId))
.Returns(new Quality(QualityTypes.DVD, true));
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(parseResultSingle, true))
.Returns(new List<Episode> { episode });
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
mocker.GetMock<QualityTypeProvider>()
Mocker.GetMock<QualityTypeProvider>()
.Setup(s => s.Get(It.IsAny<int>()))
.Returns(new QualityType { MaxSize = 100, MinSize = 0 });
episode.EpisodeFile.Quality = QualityTypes.SDTV;
//Act
bool result = mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
//Assert
Assert.IsFalse(result);
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsQualityNeeded_lesser_file_in_history_should_be_downloaded()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series.QualityProfile = sdProfile;
parseResultSingle.Quality.QualityType = QualityTypes.DVD;
mocker.GetMock<HistoryProvider>()
Mocker.GetMock<HistoryProvider>()
.Setup(p => p.GetBestQualityInHistory(episode.EpisodeId))
.Returns(new Quality(QualityTypes.SDTV, true));
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(parseResultSingle, true))
.Returns(new List<Episode> { episode });
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
mocker.GetMock<QualityTypeProvider>()
Mocker.GetMock<QualityTypeProvider>()
.Setup(s => s.Get(It.IsAny<int>()))
.Returns(new QualityType { MaxSize = 100, MinSize = 0 });
episode.EpisodeFile.Quality = QualityTypes.SDTV;
//Act
bool result = mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
//Assert
result.Should().BeTrue();
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void IsQualityNeeded_file_not_in_history_should_be_downloaded()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
parseResultSingle.Series.QualityProfile = sdProfile;
parseResultSingle.Quality.QualityType = QualityTypes.DVD;
mocker.GetMock<HistoryProvider>()
Mocker.GetMock<HistoryProvider>()
.Setup(p => p.GetBestQualityInHistory(episode.EpisodeId))
.Returns<Quality>(null);
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.GetEpisodesByParseResult(parseResultSingle, true))
.Returns(new List<Episode> { episode });
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(p => p.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns(false);
mocker.GetMock<QualityTypeProvider>()
Mocker.GetMock<QualityTypeProvider>()
.Setup(s => s.Get(It.IsAny<int>()))
.Returns(new QualityType { MaxSize = 100, MinSize = 0 });
episode.EpisodeFile.Quality = QualityTypes.SDTV;
//Act
bool result = mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle);
//Assert
result.Should().BeTrue();
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
//Should Download

View File

@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var secondSeriesFiles = Builder<EpisodeFile>.CreateListOfSize(10)
.All().With(s => s.SeriesId = 20).Build();
var mocker = new AutoMoqer();
var database = TestDbHelper.GetEmptyDatabase(true);
@ -36,9 +36,9 @@ namespace NzbDrone.Core.Test.ProviderTests
database.InsertMany(firstSeriesFiles);
database.InsertMany(secondSeriesFiles);
mocker.SetConstant(database);
Mocker.SetConstant(database);
var result = mocker.Resolve<MediaFileProvider>().GetSeriesFiles(12);
var result = Mocker.Resolve<MediaFileProvider>().GetSeriesFiles(12);
result.Should().HaveSameCount(firstSeriesFiles);
@ -59,16 +59,16 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(s => s.SeasonNumber = 2)
.Build();
var mocker = new AutoMoqer();
var database = TestDbHelper.GetEmptyDatabase(true);
database.InsertMany(firstSeriesFiles);
database.InsertMany(secondSeriesFiles);
mocker.SetConstant(database);
Mocker.SetConstant(database);
var result = mocker.Resolve<MediaFileProvider>().GetSeasonFiles(12, 1);
var result = Mocker.Resolve<MediaFileProvider>().GetSeasonFiles(12, 1);
result.Should().HaveSameCount(firstSeriesFiles);
}
@ -76,19 +76,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void Scan_series_should_skip_series_with_no_episodes()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetEpisodeBySeries(12))
.Returns(new List<Episode>());
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.RepairLinks()).Returns(0);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.DeleteOrphaned()).Returns(0);
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
@ -96,10 +96,10 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(s => s.SeriesId = 12).Build();
//Act
mocker.Resolve<DiskScanProvider>().Scan(series);
Mocker.Resolve<DiskScanProvider>().Scan(series);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
@ -120,13 +120,13 @@ namespace NzbDrone.Core.Test.ProviderTests
//Setup
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
var mocker = new AutoMoqer();
var database = TestDbHelper.GetEmptyDatabase(true);
mocker.SetConstant(database);
Mocker.SetConstant(database);
database.InsertMany(episodes);
//Act
var removedLinks = mocker.Resolve<MediaFileProvider>().RepairLinks();
var removedLinks = Mocker.Resolve<MediaFileProvider>().RepairLinks();
var result = database.Fetch<Episode>();
//Assert
@ -142,14 +142,14 @@ namespace NzbDrone.Core.Test.ProviderTests
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10).Build();
var episodes = Builder<Episode>.CreateListOfSize(5).Build();
var mocker = new AutoMoqer();
var database = TestDbHelper.GetEmptyDatabase(true);
mocker.SetConstant(database);
Mocker.SetConstant(database);
database.InsertMany(episodes);
database.InsertMany(episodeFiles);
//Act
mocker.Resolve<MediaFileProvider>().DeleteOrphaned();
Mocker.Resolve<MediaFileProvider>().DeleteOrphaned();
var result = database.Fetch<EpisodeFile>();
//Assert
@ -172,11 +172,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(s => s.SeasonFolder = useSeasonFolder)
.Build();
var mocker = new AutoMoqer();
mocker.GetMock<ConfigProvider>().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat);
Mocker.GetMock<ConfigProvider>().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat);
//Act
var result = mocker.Resolve<MediaFileProvider>().CalculateFilePath(fakeSeries, 1, filename, ".mkv");
var result = Mocker.Resolve<MediaFileProvider>().CalculateFilePath(fakeSeries, 1, filename, ".mkv");
//Assert
Assert.AreEqual(expectedPath, result.FullName);
@ -188,13 +188,13 @@ namespace NzbDrone.Core.Test.ProviderTests
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10).Build();
var mocker = new AutoMoqer();
var database = TestDbHelper.GetEmptyDatabase(true);
mocker.SetConstant(database);
Mocker.SetConstant(database);
database.InsertMany(episodeFiles);
//Act
mocker.Resolve<MediaFileProvider>().Delete(1);
Mocker.Resolve<MediaFileProvider>().Delete(1);
var result = database.Fetch<EpisodeFile>();
//Assert

View File

@ -21,9 +21,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
//Assert
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV]", result);
@ -48,9 +48,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_Episode_Quality_1x05_Dash()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
//Assert
Assert.AreEqual("15x06 - City Sushi [HDTV]", result);
@ -75,9 +75,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_Series_Quality_01x05_Space()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
//Assert
Assert.AreEqual("South Park 05x06 [HDTV]", result);
@ -102,9 +102,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_Series_s01e05_Space()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
//Assert
Assert.AreEqual("South Park s05e06", result);
@ -130,9 +130,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_Series_Episode_s01e05_Periods()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
//Assert
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
@ -157,9 +157,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
@ -174,7 +174,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
//Assert
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV]", result);
@ -184,9 +184,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_S01E05_Dash()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV);
//Assert
Assert.AreEqual("S15E06", result);
@ -212,9 +212,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
@ -236,7 +236,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
//Assert
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -246,9 +246,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
@ -270,7 +270,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
//Assert
Assert.AreEqual("3x23x24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -280,9 +280,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
@ -304,7 +304,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
//Assert
Assert.AreEqual("3x23x24 Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -314,9 +314,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
@ -338,7 +338,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
//Assert
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream.(1).+.Strawberries.and.Cream.(2)", result);
@ -348,9 +348,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
@ -372,7 +372,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
//Assert
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
@ -382,9 +382,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
{
//Setup
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
@ -406,7 +406,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
//Act
string result = mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV);
//Assert
Assert.AreEqual("3x23x24", result);

View File

@ -7,12 +7,13 @@ using NUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
public class MisnamedProviderTest
public class MisnamedProviderTest : CoreTest
{
[Test]
public void no_misnamed_files()
@ -42,22 +43,22 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
mocker.GetMock<EpisodeProvider>()
WithStrictMocker();
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> {episodes[0]}, "SeriesTitle", It.IsAny<QualityTypes>()))
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("Title1");
mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> {episodes[1]}, "SeriesTitle", It.IsAny<QualityTypes>()))
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(0);
@ -91,22 +92,22 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("New Title 1");
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("New Title 2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(2);
@ -140,22 +141,22 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("New Title 1");
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(1);
@ -191,22 +192,22 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("New Title 1");
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(1);
@ -242,22 +243,22 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
mocker.GetMock<EpisodeProvider>()
Mocker.GetMock<EpisodeProvider>()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("Title1");
mocker.GetMock<MediaFileProvider>()
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>()))
.Returns("Title2");
//Act
var totalItems = 0;
var misnamedEpisodes = mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
var misnamedEpisodes = Mocker.Resolve<MisnamedProvider>().MisnamedFiles(1, 10, out totalItems);
//Assert
misnamedEpisodes.Should().HaveCount(0);

View File

@ -23,12 +23,12 @@ namespace NzbDrone.Core.Test.ProviderTests
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "http://www.nzbdrone.com/gibberish/test.aspx?hello=world" };
var expectedUrl = "http://www.nzbdrone.com";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
var result = mocker.Resolve<NewznabProvider>().Save(newznab);
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
//Assert
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
@ -42,15 +42,15 @@ namespace NzbDrone.Core.Test.ProviderTests
var expectedUrl = "http://www.nzbdrone.com";
var newUrl = "http://www.nzbdrone.com/gibberish/test.aspx?hello=world";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
newznab.Id = Convert.ToInt32(db.Insert(newznab));
newznab.Url = newUrl;
//Act
var result = mocker.Resolve<NewznabProvider>().Save(newznab);
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
//Assert
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
@ -63,12 +63,12 @@ namespace NzbDrone.Core.Test.ProviderTests
var newznab = new NewznabDefinition { Name = "Newznab Provider", Enable = true, Url = "" };
var expectedUrl = "";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
var result = mocker.Resolve<NewznabProvider>().Save(newznab);
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
//Assert
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
@ -82,15 +82,15 @@ namespace NzbDrone.Core.Test.ProviderTests
var expectedUrl = "";
var newUrl = "";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
newznab.Id = Convert.ToInt32(db.Insert(newznab));
newznab.Url = newUrl;
//Act
var result = mocker.Resolve<NewznabProvider>().Save(newznab);
var result = Mocker.Resolve<NewznabProvider>().Save(newznab);
//Assert
db.Single<NewznabDefinition>(result).Url.Should().Be(expectedUrl);
@ -107,16 +107,16 @@ namespace NzbDrone.Core.Test.ProviderTests
var expectedUrl = "http://www.nzbdrone.com";
var newUrl = "http://www.nzbdrone.com/gibberish/test.aspx?hello=world";
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(definitions);
definitions.ToList().ForEach(d => d.Url = newUrl);
//Act
mocker.Resolve<NewznabProvider>().SaveAll(definitions);
Mocker.Resolve<NewznabProvider>().SaveAll(definitions);
//Assert
db.Fetch<NewznabDefinition>().Where(d => d.Url == expectedUrl).Should().HaveCount(5);
@ -133,14 +133,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(d => d.Enable = true)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(definitions);
//Act
var result = mocker.Resolve<NewznabProvider>().Enabled();
var result = Mocker.Resolve<NewznabProvider>().Enabled();
//Assert
result.Should().HaveCount(3);
@ -158,14 +158,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(d => d.Enable = true)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(definitions);
//Act
var result = mocker.Resolve<NewznabProvider>().All();
var result = Mocker.Resolve<NewznabProvider>().All();
//Assert
result.Should().HaveCount(5);
@ -182,14 +182,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(d => d.Enable = true)
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.InsertMany(definitions);
//Act
mocker.Resolve<NewznabProvider>().Delete(1);
Mocker.Resolve<NewznabProvider>().Delete(1);
//Assert
var result = db.Fetch<NewznabDefinition>();
@ -206,12 +206,12 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(d => d.Url = "http://www.nzbdrone.com")
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(definitions);
Mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(definitions);
//Assert
var result = db.Fetch<NewznabDefinition>();
@ -231,15 +231,15 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(d => d.Url = "http://www.nzbdrone.com")
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(definitions[0]);
db.Insert(definitions[1]);
//Act
mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(definitions);
Mocker.Resolve<NewznabProvider>().InitializeNewznabIndexers(definitions);
//Assert
var result = db.Fetch<NewznabDefinition>();

View File

@ -23,30 +23,28 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
[Test]
public void should_skip_if_folder_is_tagged_and_too_fresh()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var droppedFolder = new DirectoryInfo(TempFolder + "\\_test\\");
droppedFolder.Create();
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
}
[Test]
public void should_continue_processing_if_folder_is_tagged_and_not_fresh()
{
var mocker = new AutoMoqer(MockBehavior.Loose);
var droppedFolder = new DirectoryInfo(TempFolder + "\\_test\\");
droppedFolder.Create();
droppedFolder.LastWriteTime = DateTime.Now.AddMinutes(-2);
//Act
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null).Verifiable();
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null).Verifiable();
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
ExceptionVerification.ExcpectedWarns(1);
}
@ -54,17 +52,15 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
[Test]
public void should_search_for_series_using_title_without_status()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Loose);
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\_unpack_The Office - S01E01 - Episode Title");
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns<Series>(null).Verifiable();
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns<Series>(null).Verifiable();
//Act
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
ExceptionVerification.ExcpectedWarns(1);
}
@ -72,19 +68,19 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
public void when_series_isnt_found_folder_should_be_tagged_as_unknown_series()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
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<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns<Series>(null);
mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns<Series>(null);
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
ExceptionVerification.ExcpectedWarns(1);
}
@ -92,7 +88,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
public void when_no_files_are_imported_folder_should_be_tagged_with_parse_error()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - S01E01 - Episode Title");
var taggedFolder = @"C:\Test\Unsorted TV\_ParseError_The Office - S01E01 - Episode Title";
@ -102,16 +98,16 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
.Build();
//Act
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("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));
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("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));
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
ExceptionVerification.ExcpectedWarns(1);
}
@ -120,7 +116,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
public void when_no_file_are_imported_and_folder_size_isnt_small_enought_folder_should_be_tagged_unknown()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - Season 01");
var taggedFolder = PostDownloadProvider.GetTaggedFolderName(droppedFolder, PostDownloadStatusType.Unknown);
@ -135,16 +131,16 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
.Build().ToList();
//Act
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("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());
mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(true);
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("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());
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
Mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(true);
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
ExceptionVerification.ExcpectedWarns(1);
}
@ -155,39 +151,39 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
public void folder_shouldnt_be_tagged_with_same_tag_again(string path)
{
//Setup
var mocker = new AutoMoqer();
var droppedFolder = new DirectoryInfo(TempFolder + path);
droppedFolder.Create();
droppedFolder.LastWriteTime = DateTime.Now.AddHours(-1);
//Act
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(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());
Mocker.VerifyAllMocks();
Mocker.GetMock<DiskProvider>().Verify(c => c.MoveDirectory(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
}
[Test]
public void folder_should_be_tagged_if_existing_tag_is_diffrent()
{
//Setup
var mocker = new AutoMoqer();
var droppedFolder = new DirectoryInfo(TempFolder + @"\_UnknownEpisode_The Office - S01E01 - Episode Title");
droppedFolder.Create();
droppedFolder.LastWriteTime = DateTime.Now.AddHours(-1);
var taggedFolder = TempFolder + @"\_UnknownSeries_The Office - S01E01 - Episode Title";
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
//Act
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.VerifyAllMocks();
mocker.GetMock<DiskProvider>().Verify(c => c.MoveDirectory(droppedFolder.FullName, taggedFolder), Times.Once());
Mocker.VerifyAllMocks();
Mocker.GetMock<DiskProvider>().Verify(c => c.MoveDirectory(droppedFolder.FullName, taggedFolder), Times.Once());
ExceptionVerification.ExcpectedWarns(1);
}
@ -195,7 +191,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
public void when_files_are_imported_and_folder_is_small_enought_dir_should_be_deleted()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\The Office - Season 01");
var fakeSeries = Builder<Series>.CreateNew()
@ -207,24 +203,22 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
.With(f => f.SeriesId = fakeSeries.SeriesId)
.Build().ToList();
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(true);
mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes());
mocker.GetMock<DiskProvider>().Setup(s => s.DeleteFolder(droppedFolder.FullName, true));
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
Mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(true);
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes());
Mocker.GetMock<DiskProvider>().Setup(s => s.DeleteFolder(droppedFolder.FullName, true));
//Act
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void all_imported_files_should_be_moved()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Loose);
var droppedFolder = new DirectoryInfo(TempFolder);
var fakeSeries = Builder<Series>.CreateNew()
@ -233,16 +227,16 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
var fakeEpisodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
.Build().ToList();
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<string>())).Returns(fakeSeries);
mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<string>())).Returns(fakeSeries);
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
//Act
mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
//Assert
mocker.GetMock<DiskScanProvider>().Verify(c => c.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true),
Mocker.GetMock<DiskScanProvider>().Verify(c => c.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true),
Times.Exactly(fakeEpisodeFiles.Count));
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}

View File

@ -30,10 +30,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void Verify_should_return_true_for_a_valid_apiKey()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().Verify(_apiKey);
var result = Mocker.Resolve<ProwlProvider>().Verify(_apiKey);
//Assert
result.Should().BeTrue();
@ -43,10 +43,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void Verify_should_return_false_for_an_invalid_apiKey()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().Verify(_badApiKey);
var result = Mocker.Resolve<ProwlProvider>().Verify(_badApiKey);
//Assert
ExceptionVerification.ExcpectedWarns(1);
@ -57,10 +57,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_should_return_true_for_a_valid_apiKey()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey);
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey);
//Assert
result.Should().BeTrue();
@ -70,10 +70,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_should_return_false_for_an_invalid_apiKey()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _badApiKey);
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _badApiKey);
//Assert
ExceptionVerification.ExcpectedWarns(1);
@ -84,10 +84,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_should_alert_with_high_priority()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (High)", _apiKey, NotificationPriority.High);
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (High)", _apiKey, NotificationPriority.High);
//Assert
result.Should().BeTrue();
@ -97,10 +97,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_should_alert_with_VeryLow_priority()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (VeryLow)", _apiKey, NotificationPriority.VeryLow);
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (VeryLow)", _apiKey, NotificationPriority.VeryLow);
//Assert
result.Should().BeTrue();
@ -110,10 +110,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_should_have_a_call_back_url()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey, NotificationPriority.Normal, "http://www.nzbdrone.com");
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();
@ -123,10 +123,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_should_return_true_for_two_valid_apiKey()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _apiKey2);
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _apiKey2);
//Assert
result.Should().BeTrue();
@ -136,10 +136,10 @@ namespace NzbDrone.Core.Test.ProviderTests
public void SendNotification_should_return_true_for_valid_apiKey_with_bad_apiKey()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
//Act
var result = mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _badApiKey);
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _badApiKey);
//Assert
result.Should().BeTrue();

View File

@ -19,15 +19,15 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void SetupDefault_should_add_six_profiles()
{
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
mocker.Resolve<QualityTypeProvider>().SetupDefault();
Mocker.Resolve<QualityTypeProvider>().SetupDefault();
//Assert
var types = mocker.Resolve<QualityTypeProvider>().All();
var types = Mocker.Resolve<QualityTypeProvider>().All();
types.Should().HaveCount(6);
types.Should().Contain(e => e.Name == "SDTV" && e.QualityTypeId == 1);
@ -41,9 +41,9 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void SetupDefault_already_exists()
{
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
var fakeQualityType = Builder<QualityType>.CreateNew()
.Build();
@ -51,10 +51,10 @@ namespace NzbDrone.Core.Test.ProviderTests
db.Insert(fakeQualityType);
//Act
mocker.Resolve<QualityTypeProvider>().SetupDefault();
Mocker.Resolve<QualityTypeProvider>().SetupDefault();
//Assert
var types = mocker.Resolve<QualityTypeProvider>().All();
var types = Mocker.Resolve<QualityTypeProvider>().All();
types.Should().HaveCount(1);
}
@ -62,9 +62,9 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetList_single_quality_type()
{
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
.Build();
@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.ProviderTests
db.InsertMany(fakeQualityTypes);
//Act
var result = mocker.Resolve<QualityTypeProvider>().GetList(ids);
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
//Assert
result.Should().HaveCount(ids.Count);
@ -83,9 +83,9 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetList_multiple_quality_type()
{
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
.Build();
@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.ProviderTests
db.InsertMany(fakeQualityTypes);
//Act
var result = mocker.Resolve<QualityTypeProvider>().GetList(ids);
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
//Assert
result.Should().HaveCount(ids.Count);

View File

@ -24,19 +24,19 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetRootDirs()
{
//Setup
var mocker = new AutoMoqer();
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(emptyDatabase);
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(new RootDir { Path = @"C:\TV" });
emptyDatabase.Insert(new RootDir { Path = @"C:\TV2" });
//mocker.GetMock<IRepository>()
//Mocker.GetMock<IRepository>()
// .Setup(f => f.All<RootDir>())
// .Returns(sonicRepo.All<RootDir>);
//Act
var result = mocker.Resolve<RootDirProvider>().GetAll();
var result = Mocker.Resolve<RootDirProvider>().GetAll();
//Assert
Assert.AreEqual(result.Count, 2);
@ -47,11 +47,11 @@ namespace NzbDrone.Core.Test.ProviderTests
public void AddRootDir(string path)
{
//Setup
var mocker = new AutoMoqer();
mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
var rootDirProvider = mocker.Resolve<RootDirProvider>();
var rootDirProvider = Mocker.Resolve<RootDirProvider>();
rootDirProvider.Add(new RootDir { Path = path });
@ -67,11 +67,11 @@ namespace NzbDrone.Core.Test.ProviderTests
public void RemoveRootDir()
{
//Setup
var mocker = new AutoMoqer();
mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
var rootDirProvider = mocker.Resolve<RootDirProvider>();
var rootDirProvider = Mocker.Resolve<RootDirProvider>();
rootDirProvider.Add(new RootDir { Path = @"C:\TV" });
rootDirProvider.Remove(1);
@ -84,14 +84,14 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetRootDir()
{
//Setup
var mocker = new AutoMoqer();
mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
const int id = 1;
const string path = @"C:\TV";
//Act
var rootDirProvider = mocker.Resolve<RootDirProvider>();
var rootDirProvider = Mocker.Resolve<RootDirProvider>();
rootDirProvider.Add(new RootDir { Id = id, Path = path });
//Assert
@ -105,24 +105,24 @@ namespace NzbDrone.Core.Test.ProviderTests
{
const string path = "d:\\bad folder";
var mocker = new AutoMoqer();
mocker.GetMock<DiskProvider>(MockBehavior.Strict)
Mocker.GetMock<DiskProvider>(MockBehavior.Strict)
.Setup(m => m.FolderExists(path)).Returns(false);
var result = mocker.Resolve<RootDirProvider>().GetUnmappedFolders(path);
var result = Mocker.Resolve<RootDirProvider>().GetUnmappedFolders(path);
result.Should().NotBeNull();
result.Should().BeEmpty();
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void empty_folder_path_throws()
{
var mocker = new AutoMoqer();
mocker.Resolve<RootDirProvider>().GetUnmappedFolders("");
Mocker.Resolve<RootDirProvider>().GetUnmappedFolders("");
}
[TestCase("")]
@ -131,8 +131,8 @@ namespace NzbDrone.Core.Test.ProviderTests
[ExpectedException(typeof(ArgumentException))]
public void invalid_folder_path_throws_on_add(string path)
{
var mocker = new AutoMoqer();
mocker.Resolve<RootDirProvider>().Add(new RootDir { Id = 0, Path = path });
Mocker.Resolve<RootDirProvider>().Add(new RootDir { Id = 0, Path = path });
}
}

View File

@ -36,9 +36,9 @@ namespace NzbDrone.Core.Test.ProviderTests
const string category = "tv";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeConfig.SetupGet(c => c.SabTvCategory)
.Returns(category);
mocker.GetMock<HttpProvider>(MockBehavior.Strict)
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
.Setup(
s =>
s.DownloadString(
@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns("ok");
//Act
bool result = mocker.Resolve<SabProvider>().AddByUrl(
bool result = Mocker.Resolve<SabProvider>().AddByUrl(
"http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
//Assert
@ -83,9 +83,9 @@ namespace NzbDrone.Core.Test.ProviderTests
const string category = "tv";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeConfig.SetupGet(c => c.SabTvCategory)
.Returns(category);
mocker.GetMock<HttpProvider>(MockBehavior.Strict)
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
.Setup(
s =>
s.DownloadString(
@ -109,7 +109,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns("ok");
//Act
bool result = mocker.Resolve<SabProvider>().AddByUrl(
bool result = Mocker.Resolve<SabProvider>().AddByUrl(
"http://www.newzbin.com/browse/post/6107863/nzb", "This is an Nzb");
//Assert
@ -128,9 +128,9 @@ namespace NzbDrone.Core.Test.ProviderTests
var priority = SabnzbdPriorityType.Normal;
string category = "tv";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
@ -145,12 +145,12 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns(priority);
fakeConfig.SetupGet(c => c.SabTvCategory)
.Returns(category);
mocker.GetMock<HttpProvider>()
Mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString(It.IsAny<String>()))
.Returns("error");
//Act
var sabProvider = mocker.Resolve<SabProvider>();
var sabProvider = Mocker.Resolve<SabProvider>();
var result = sabProvider.AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an nzb");
//Assert
@ -168,9 +168,9 @@ namespace NzbDrone.Core.Test.ProviderTests
string username = "admin";
string password = "pass";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
@ -182,12 +182,12 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeConfig.SetupGet(c => c.SabPassword)
.Returns(password);
mocker.GetMock<HttpProvider>(MockBehavior.Strict)
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(File.ReadAllText(@".\Files\Queue.xml"));
//Act
bool result = mocker.Resolve<SabProvider>().IsInQueue("Ubuntu Test");
bool result = Mocker.Resolve<SabProvider>().IsInQueue("Ubuntu Test");
//Assert
result.Should().BeTrue();
@ -203,9 +203,9 @@ namespace NzbDrone.Core.Test.ProviderTests
string username = "admin";
string password = "pass";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
@ -217,12 +217,12 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeConfig.SetupGet(c => c.SabPassword)
.Returns(password);
mocker.GetMock<HttpProvider>(MockBehavior.Strict)
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(File.ReadAllText(@".\Files\QueueEmpty.xml"));
//Act
bool result = mocker.Resolve<SabProvider>().IsInQueue(String.Empty);
bool result = Mocker.Resolve<SabProvider>().IsInQueue(String.Empty);
//Assert
Assert.IsFalse(result);
@ -239,9 +239,9 @@ namespace NzbDrone.Core.Test.ProviderTests
string username = "admin";
string password = "pass";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
@ -253,13 +253,13 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeConfig.SetupGet(c => c.SabPassword)
.Returns(password);
mocker.GetMock<HttpProvider>(MockBehavior.Strict)
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(File.ReadAllText(@".\Files\QueueError.xml"));
//Act
mocker.Resolve<SabProvider>().IsInQueue(String.Empty);
Mocker.Resolve<SabProvider>().IsInQueue(String.Empty);
}
[Test]
@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[TestCase(1, new[] { 2, 4 }, "", QualityTypes.HDTV, true, "My Series Name - 1x2-1x4 - [HDTV] [Proper]")]
public void sab_title(int seasons, int[] episodes, string title, QualityTypes quality, bool proper, string expected)
{
var mocker = new AutoMoqer();
var series = Builder<Series>.CreateNew()
.With(c => c.Path = @"d:\tv shows\My Series Name")
@ -288,7 +288,7 @@ namespace NzbDrone.Core.Test.ProviderTests
};
//Act
var actual = mocker.Resolve<SabProvider>().GetSabTitle(parsResult);
var actual = Mocker.Resolve<SabProvider>().GetSabTitle(parsResult);
//Assert
Assert.AreEqual(expected, actual);
@ -298,7 +298,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[TestCase(false, "My Series Name - Season 1 [Bluray720p]")]
public void sab_season_title(bool proper, string expected)
{
var mocker = new AutoMoqer();
var series = Builder<Series>.CreateNew()
.With(c => c.Path = @"d:\tv shows\My Series Name")
@ -315,7 +315,7 @@ namespace NzbDrone.Core.Test.ProviderTests
};
//Act
var actual = mocker.Resolve<SabProvider>().GetSabTitle(parsResult);
var actual = Mocker.Resolve<SabProvider>().GetSabTitle(parsResult);
//Assert
Assert.AreEqual(expected, actual);
@ -325,7 +325,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[TestCase(false, "My Series Name - 2011-12-01 - My Episode Title [Bluray720p]")]
public void sab_daily_series_title(bool proper, string expected)
{
var mocker = new AutoMoqer();
var series = Builder<Series>.CreateNew()
.With(c => c.Path = @"d:\tv shows\My Series Name")
@ -341,7 +341,7 @@ namespace NzbDrone.Core.Test.ProviderTests
};
//Act
var actual = mocker.Resolve<SabProvider>().GetSabTitle(parsResult);
var actual = Mocker.Resolve<SabProvider>().GetSabTitle(parsResult);
//Assert
Assert.AreEqual(expected, actual);
@ -361,9 +361,9 @@ namespace NzbDrone.Core.Test.ProviderTests
const string category = "tv";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
@ -380,10 +380,10 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns(category);
mocker.SetConstant(new HttpProvider());
Mocker.SetConstant(new HttpProvider());
//Act
bool result = mocker.Resolve<SabProvider>().AddByUrl(
bool result = Mocker.Resolve<SabProvider>().AddByUrl(
"http://www.newzbin.com/browse/post/6107863/nzb", "Added by unit tests.");
//Assert
@ -400,14 +400,14 @@ namespace NzbDrone.Core.Test.ProviderTests
const string username = "admin";
const string password = "pass";
var mocker = new AutoMoqer();
mocker.GetMock<HttpProvider>(MockBehavior.Strict)
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
.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(File.ReadAllText(@".\Files\Categories_json.txt"));
//Act
var result = mocker.Resolve<SabProvider>().GetCategories(host, port, apikey, username, password);
var result = Mocker.Resolve<SabProvider>().GetCategories(host, port, apikey, username, password);
//Assert
result.Should().NotBeNull();
@ -425,9 +425,9 @@ namespace NzbDrone.Core.Test.ProviderTests
const string username = "admin";
const string password = "pass";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(host);
fakeConfig.SetupGet(c => c.SabPort)
@ -439,12 +439,12 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeConfig.SetupGet(c => c.SabPassword)
.Returns(password);
mocker.GetMock<HttpProvider>(MockBehavior.Strict)
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
.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(File.ReadAllText(@".\Files\Categories_json.txt"));
//Act
var result = mocker.Resolve<SabProvider>().GetCategories();
var result = Mocker.Resolve<SabProvider>().GetCategories();
//Assert
result.Should().NotBeNull();

View File

@ -43,14 +43,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "Law and Order")
.Build();
var mocker = new AutoMoqer();
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(emptyDatabase);
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
//Assert
Assert.AreEqual(fakeMap.SceneName, sceneName);
@ -66,14 +66,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder")
.Build();
var mocker = new AutoMoqer();
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(emptyDatabase);
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
//Assert
Assert.AreEqual(fakeMap.SeriesId, seriesId);
@ -89,14 +89,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder")
.Build();
var mocker = new AutoMoqer();
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(emptyDatabase);
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(54321);
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(54321);
//Assert
Assert.AreEqual(null, sceneName);
@ -112,14 +112,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.CleanTitle = "laworder")
.Build();
var mocker = new AutoMoqer();
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(emptyDatabase);
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder");
var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder");
//Assert
Assert.AreEqual(null, seriesId);
@ -143,16 +143,16 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "The Office")
.Build();
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
db.Insert(fakeMap);
db.Insert(fakeMap2);
//Act
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
//Assert
Assert.AreEqual(fakeMap.SceneName, sceneName);

View File

@ -50,14 +50,14 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
//Assert
result.Should().HaveCount(1);
@ -71,14 +71,14 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Today();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Today();
//Assert
result.Should().HaveCount(1);
@ -92,14 +92,14 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
//Assert
result.Should().HaveCount(1);
@ -113,14 +113,14 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
database.InsertMany(episodes);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Week();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
//Assert
result.Should().HaveCount(2);
@ -135,8 +135,8 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).Single().Ignored = true;
@ -144,7 +144,7 @@ namespace NzbDrone.Core.Test.ProviderTests
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
//Assert
result.Should().BeEmpty();
@ -155,8 +155,8 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today).Single().Ignored = true;
@ -164,7 +164,7 @@ namespace NzbDrone.Core.Test.ProviderTests
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Today();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Today();
//Assert
result.Should().BeEmpty();
@ -175,8 +175,8 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(1)).Single().Ignored = true;
@ -184,7 +184,7 @@ namespace NzbDrone.Core.Test.ProviderTests
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
//Assert
result.Should().BeEmpty();
@ -195,8 +195,8 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var database = TestDbHelper.GetEmptyDatabase();
var mocker = new AutoMoqer();
mocker.SetConstant(database);
Mocker.SetConstant(database);
episodes.Where(e => e.AirDate == DateTime.Today.AddDays(2)).Single().Ignored = true;
@ -204,7 +204,7 @@ namespace NzbDrone.Core.Test.ProviderTests
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Week();
var result = Mocker.Resolve<UpcomingEpisodesProvider>().Week();
//Assert
result.Should().HaveCount(1);

View File

@ -13,8 +13,6 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{
class GetAvilableUpdateFixture : CoreTest
{
private AutoMoqer _mocker = null;
private static Version _latestsTestVersion = new Version("0.6.0.3");
private static string _latestsTestUrl = "http://update.nzbdrone.com/_test/NzbDrone.master.0.6.0.3.zip";
private static string _latestsTestFileName = "NzbDrone.master.0.6.0.3.zip";
@ -22,10 +20,10 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
[SetUp]
public void setup()
{
_mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
_mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
_mocker.Resolve<HttpProvider>();
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
Mocker.Resolve<HttpProvider>();
}
[TestCase("0.6.0.9")]
@ -33,9 +31,9 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
[TestCase("1.0.0.0")]
public void should_return_null_if_latests_is_lower_than_current_version(string currentVersion)
{
_mocker.GetMock<EnviromentProvider>().SetupGet(c => c.Version).Returns(new Version(currentVersion));
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.Version).Returns(new Version(currentVersion));
var updatePackage = _mocker.Resolve<UpdateProvider>().GetAvilableUpdate();
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate();
updatePackage.Should().BeNull();
}
@ -43,9 +41,9 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
[Test]
public void should_return_null_if_latests_is_equal_to_current_version()
{
_mocker.GetMock<EnviromentProvider>().SetupGet(c => c.Version).Returns(_latestsTestVersion);
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.Version).Returns(_latestsTestVersion);
var updatePackage = _mocker.Resolve<UpdateProvider>().GetAvilableUpdate();
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate();
updatePackage.Should().BeNull();
}
@ -55,9 +53,9 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
[TestCase("0.0.10.10")]
public void should_return_update_if_latests_is_higher_than_current_version(string currentVersion)
{
_mocker.GetMock<EnviromentProvider>().SetupGet(c => c.Version).Returns(new Version(currentVersion));
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.Version).Returns(new Version(currentVersion));
var updatePackage = _mocker.Resolve<UpdateProvider>().GetAvilableUpdate();
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate();
updatePackage.Should().NotBeNull();
updatePackage.Version.Should().Be(_latestsTestVersion);

View File

@ -24,11 +24,11 @@ namespace NzbDrone.Core.Test.ProviderTests
public void JsonError_true()
{
//Setup
var mocker = new AutoMoqer();
var response = "{\"error\":{\"code\":-32601,\"message\":\"Method not found.\"},\"id\":10,\"jsonrpc\":\"2.0\"}";
//Act
var result = mocker.Resolve<XbmcProvider>().CheckForJsonError(response);
var result = Mocker.Resolve<XbmcProvider>().CheckForJsonError(response);
//Assert
Assert.AreEqual(true, result);
@ -38,11 +38,11 @@ namespace NzbDrone.Core.Test.ProviderTests
public void JsonError_true_empty_response()
{
//Setup
var mocker = new AutoMoqer();
var response = String.Empty;
//Act
var result = mocker.Resolve<XbmcProvider>().CheckForJsonError(response);
var result = Mocker.Resolve<XbmcProvider>().CheckForJsonError(response);
//Assert
Assert.AreEqual(true, result);
@ -52,11 +52,11 @@ namespace NzbDrone.Core.Test.ProviderTests
public void JsonError_false()
{
//Setup
var mocker = new AutoMoqer();
var reposnse = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":3}}";
//Act
var result = mocker.Resolve<XbmcProvider>().CheckForJsonError(reposnse);
var result = Mocker.Resolve<XbmcProvider>().CheckForJsonError(reposnse);
//Assert
Assert.AreEqual(false, result);
@ -68,16 +68,16 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetJsonVersion(int number)
{
//Setup
var mocker = new AutoMoqer();
var message = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"version\":" + number + "}}";
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
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");
var result = Mocker.Resolve<XbmcProvider>().GetJsonVersion("localhost:8080", "xbmc", "xbmc");
//Assert
Assert.AreEqual(number, result);
@ -87,16 +87,16 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetJsonVersion_error()
{
//Setup
var mocker = new AutoMoqer();
var message = "{\"error\":{\"code\":-32601,\"message\":\"Method not found.\"},\"id\":10,\"jsonrpc\":\"2.0\"}";
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
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");
var result = Mocker.Resolve<XbmcProvider>().GetJsonVersion("localhost:8080", "xbmc", "xbmc");
//Assert
Assert.AreEqual(0, result);
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetActivePlayers(bool audio, bool picture, bool video)
{
//Setup
var mocker = new AutoMoqer();
var message = "{\"id\":10,\"jsonrpc\":\"2.0\",\"result\":{\"audio\":"
+ audio.ToString().ToLower()
@ -123,12 +123,12 @@ namespace NzbDrone.Core.Test.ProviderTests
+ video.ToString().ToLower()
+ "}}";
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny<string>()))
.Returns(message);
//Act
var result = mocker.Resolve<XbmcProvider>().GetActivePlayers("localhost:8080", "xbmc", "xbmc");
var result = Mocker.Resolve<XbmcProvider>().GetActivePlayers("localhost:8080", "xbmc", "xbmc");
//Assert
Assert.AreEqual(audio, result["audio"]);
@ -140,16 +140,16 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetTvShowsJson()
{
//Setup
var mocker = new AutoMoqer();
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}]}}";
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
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");
var result = Mocker.Resolve<XbmcProvider>().GetTvShowsJson("localhost:8080", "xbmc", "xbmc");
//Assert
Assert.AreEqual(5, result.Count);
@ -160,30 +160,30 @@ namespace NzbDrone.Core.Test.ProviderTests
public void Notify_true()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var header = "NzbDrone Test";
var message = "Test Message!";
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080");
//var fakeUdpProvider = mocker.GetMock<EventClient>();
var fakeEventClient = mocker.GetMock<EventClientProvider>();
//var fakeUdpProvider = Mocker.GetMock<EventClient>();
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);
Mocker.Resolve<XbmcProvider>().Notify(header, message);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void SendCommand()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var host = "localhost:8080";
var command = "ExecBuiltIn(CleanLibrary(video))";
@ -192,15 +192,15 @@ namespace NzbDrone.Core.Test.ProviderTests
var url = String.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(CleanLibrary(video))");
//var fakeUdpProvider = mocker.GetMock<EventClient>();
var fakeHttp = mocker.GetMock<HttpProvider>();
//var fakeUdpProvider = Mocker.GetMock<EventClient>();
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);
var result = Mocker.Resolve<XbmcProvider>().SendCommand(host, command, username, username);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
Assert.AreEqual("Ok\n", result);
}
@ -208,7 +208,7 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetXbmcSeriesPath_true()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var queryResult = @"<xml><record><field>smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/</field></record></xml>";
@ -221,8 +221,8 @@ namespace NzbDrone.Core.Test.ProviderTests
var query = String.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)");
//var fakeUdpProvider = mocker.GetMock<EventClient>();
var fakeHttp = mocker.GetMock<HttpProvider>();
//var fakeUdpProvider = Mocker.GetMock<EventClient>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.DownloadString(setResponseUrl, username, password)).Returns("<xml><tag>OK</xml>");
fakeHttp.Setup(s => s.DownloadString(resetResponseUrl, username, password)).Returns(@"<html>
<li>OK
@ -230,10 +230,10 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeHttp.Setup(s => s.DownloadString(query, username, password)).Returns(queryResult);
//Act
var result = mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
var result = Mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
Assert.AreEqual("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/", result);
}
@ -241,7 +241,7 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetXbmcSeriesPath_false()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var queryResult = @"<xml></xml>";
@ -254,8 +254,8 @@ namespace NzbDrone.Core.Test.ProviderTests
var query = String.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)");
//var fakeUdpProvider = mocker.GetMock<EventClient>();
var fakeHttp = mocker.GetMock<HttpProvider>();
//var fakeUdpProvider = Mocker.GetMock<EventClient>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.DownloadString(setResponseUrl, username, password)).Returns("<xml><tag>OK</xml>");
fakeHttp.Setup(s => s.DownloadString(resetResponseUrl, username, password)).Returns(@"<html>
<li>OK
@ -263,10 +263,10 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeHttp.Setup(s => s.DownloadString(query, username, password)).Returns(queryResult);
//Act
var result = mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
var result = Mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
Assert.AreEqual("", result);
}
@ -274,7 +274,7 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetXbmcSeriesPath_special_characters()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var queryResult = @"<xml><record><field>smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/</field></record></xml>";
@ -287,8 +287,8 @@ namespace NzbDrone.Core.Test.ProviderTests
var query = String.Format("http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)");
//var fakeUdpProvider = mocker.GetMock<EventClient>();
var fakeHttp = mocker.GetMock<HttpProvider>();
//var fakeUdpProvider = Mocker.GetMock<EventClient>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.DownloadString(setResponseUrl, username, password)).Returns("<xml><tag>OK</xml>");
fakeHttp.Setup(s => s.DownloadString(resetResponseUrl, username, password)).Returns(@"<html>
<li>OK
@ -296,10 +296,10 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeHttp.Setup(s => s.DownloadString(query, username, password)).Returns(queryResult);
//Act
var result = mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
var result = Mocker.Resolve<XbmcProvider>().GetXbmcSeriesPath(host, 79488, username, username);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
result.Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/");
}
@ -307,27 +307,24 @@ namespace NzbDrone.Core.Test.ProviderTests
public void Clean()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
WithStrictMocker();
var fakeConfig = mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080");
var fakeEventClient = mocker.GetMock<EventClientProvider>();
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(CleanLibrary(video))")).Returns(true);
//Act
mocker.Resolve<XbmcProvider>().Clean();
Mocker.Resolve<XbmcProvider>().Clean();
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void UpdateWithHttp_Single()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Default);
var host = "localhost:8080";
var username = "xbmc";
var password = "xbmc";
@ -340,23 +337,20 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(s => s.Title = "30 Rock")
.Build();
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
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);
Mocker.Resolve<XbmcProvider>().UpdateWithHttp(fakeSeries, host, username, password);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void UpdateWithHttp_All()
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Default);
var host = "localhost:8080";
var username = "xbmc";
var password = "xbmc";
@ -369,22 +363,22 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(s => s.Title = "30 Rock")
.Build();
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
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);
Mocker.Resolve<XbmcProvider>().UpdateWithHttp(fakeSeries, host, username, password);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void UpdateWithJson_Single()
{
//Setup
var mocker = new AutoMoqer();
var host = "localhost:8080";
var username = "xbmc";
@ -397,25 +391,25 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(s => s.Title = "30 Rock")
.Build();
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand(host, username, password, serializedQuery))
.Returns(tvshows);
var fakeEventClient = mocker.GetMock<EventClientProvider>();
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video,smb://HOMESERVER/TV/30 Rock/))"));
//Act
mocker.Resolve<XbmcProvider>().UpdateWithJson(fakeSeries, host, username, password);
Mocker.Resolve<XbmcProvider>().UpdateWithJson(fakeSeries, host, username, password);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
[Test]
public void UpdateWithJson_All()
{
//Setup
var mocker = new AutoMoqer();
var host = "localhost:8080";
var username = "xbmc";
@ -428,18 +422,18 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(s => s.Title = "30 Rock")
.Build();
var fakeHttp = mocker.GetMock<HttpProvider>();
var fakeHttp = Mocker.GetMock<HttpProvider>();
fakeHttp.Setup(s => s.PostCommand(host, username, password, serializedQuery))
.Returns(tvshows);
var fakeEventClient = mocker.GetMock<EventClientProvider>();
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video))"));
//Act
mocker.Resolve<XbmcProvider>().UpdateWithJson(fakeSeries, host, username, password);
Mocker.Resolve<XbmcProvider>().UpdateWithJson(fakeSeries, host, username, password);
//Assert
mocker.VerifyAllMocks();
Mocker.VerifyAllMocks();
}
}
}

View File

@ -68,9 +68,9 @@ namespace NzbDrone.Core.Test
public void Update_Success()
{
//Arrange
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
var testProfile = new QualityProfile
{
@ -85,9 +85,9 @@ namespace NzbDrone.Core.Test
//Update
currentProfile.Cutoff = QualityTypes.Bluray720p;
mocker.Resolve<QualityProvider>().Update(currentProfile);
Mocker.Resolve<QualityProvider>().Update(currentProfile);
var updated = mocker.Resolve<QualityProvider>().Get(currentProfile.QualityProfileId);
var updated = Mocker.Resolve<QualityProvider>().Get(currentProfile.QualityProfileId);
//Assert
updated.Name.Should().Be(currentProfile.Name);
@ -130,15 +130,15 @@ namespace NzbDrone.Core.Test
[Test]
public void SetupInitial_should_add_two_profiles()
{
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
//Act
mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
Mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
//Assert
var profiles = mocker.Resolve<QualityProvider>().All();
var profiles = Mocker.Resolve<QualityProvider>().All();
profiles.Should().HaveCount(2);
@ -152,17 +152,17 @@ namespace NzbDrone.Core.Test
//We don't want to keep adding them back if a user deleted them on purpose.
public void SetupInitial_should_skip_if_any_profile_exists()
{
var mocker = new AutoMoqer();
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
Mocker.SetConstant(db);
var fakeProfile = Builder<QualityProfile>.CreateNew().Build();
//Act
mocker.Resolve<QualityProvider>().Add(fakeProfile);
mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
Mocker.Resolve<QualityProvider>().Add(fakeProfile);
Mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
//Assert
var profiles = mocker.Resolve<QualityProvider>().All();
var profiles = Mocker.Resolve<QualityProvider>().All();
profiles.Should().HaveCount(1);

View File

@ -102,11 +102,11 @@ namespace NzbDrone.Core.Test
[Test]
public void get_episode_by_series_seasons_episode_x5000()
{
var mocker = new AutoMoqer();
mocker.SetConstant(db);
mocker.Resolve<SeriesProvider>();
Mocker.SetConstant(db);
Mocker.Resolve<SeriesProvider>();
var epProvider = mocker.Resolve<EpisodeProvider>();
var epProvider = Mocker.Resolve<EpisodeProvider>();
Thread.Sleep(1000);
@ -128,11 +128,11 @@ namespace NzbDrone.Core.Test
[Test]
public void get_episode_by_series_seasons_x1000()
{
var mocker = new AutoMoqer();
mocker.SetConstant(db);
mocker.Resolve<SeriesProvider>();
Mocker.SetConstant(db);
Mocker.Resolve<SeriesProvider>();
var epProvider = mocker.Resolve<EpisodeProvider>();
var epProvider = Mocker.Resolve<EpisodeProvider>();
Thread.Sleep(1000);
@ -156,11 +156,11 @@ namespace NzbDrone.Core.Test
[Test]
public void get_episode_file_count_x100()
{
var mocker = new AutoMoqer();
mocker.SetConstant(db);
mocker.Resolve<SeriesProvider>();
mocker.Resolve<EpisodeProvider>();
var mediaProvider = mocker.Resolve<MediaFileProvider>();
Mocker.SetConstant(db);
Mocker.Resolve<SeriesProvider>();
Mocker.Resolve<EpisodeProvider>();
var mediaProvider = Mocker.Resolve<MediaFileProvider>();
Thread.Sleep(1000);
@ -184,11 +184,11 @@ namespace NzbDrone.Core.Test
[Test]
public void get_episode_file_count_x1000()
{
var mocker = new AutoMoqer();
mocker.SetConstant(db);
mocker.Resolve<SeriesProvider>();
mocker.Resolve<EpisodeProvider>();
var mediaProvider = mocker.Resolve<MediaFileProvider>();
Mocker.SetConstant(db);
Mocker.Resolve<SeriesProvider>();
Mocker.Resolve<EpisodeProvider>();
var mediaProvider = Mocker.Resolve<MediaFileProvider>();
Thread.Sleep(1000);
@ -213,9 +213,9 @@ namespace NzbDrone.Core.Test
[Test]
public void get_season_count_x500()
{
var mocker = new AutoMoqer();
mocker.SetConstant(db);
var provider = mocker.Resolve<EpisodeProvider>();
Mocker.SetConstant(db);
var provider = Mocker.Resolve<EpisodeProvider>();
Thread.Sleep(1000);

View File

@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.IO;
using Moq;
using NUnit.Framework;
@ -12,7 +13,19 @@ namespace NzbDrone.Test.Common
protected const string INTEGRATION_TEST = "Integration Test";
protected AutoMoqer Mocker { get; private set; }
private AutoMoqer _mocker;
protected AutoMoqer Mocker
{
get
{
if (_mocker == null)
{
_mocker = new AutoMoqer();
}
return _mocker;
}
}
protected string VirtualPath
{
@ -34,19 +47,20 @@ namespace NzbDrone.Test.Common
}
Directory.CreateDirectory(TempFolder);
Mocker = new AutoMoqer();
}
[TearDown]
public void TestBaseTearDown()
{
_mocker = null;
}
protected void WithStrictMocker()
{
Mocker = new AutoMoqer(MockBehavior.Strict);
if (_mocker != null)
throw new InvalidOperationException("Can not switch to a strict container after container has been used. make sure this is the first call in your test.");
_mocker = new AutoMoqer(MockBehavior.Strict);
}

View File

@ -3,11 +3,9 @@ using System;
using System.IO;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
using NzbDrone.Update.Providers;
namespace NzbDrone.Update.Test
@ -16,17 +14,14 @@ namespace NzbDrone.Update.Test
class UpdateProviderVerifyFixture : TestBase
{
AutoMoqer mocker = new AutoMoqer();
[SetUp]
public void Setup()
{
mocker = new AutoMoqer();
mocker.GetMock<EnviromentProvider>()
Mocker.GetMock<EnviromentProvider>()
.Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\");
mocker.GetMock<EnviromentProvider>()
Mocker.GetMock<EnviromentProvider>()
.Setup(c => c.SystemTemp).Returns(@"C:\Temp\");
}
@ -35,7 +30,7 @@ namespace NzbDrone.Update.Test
[TestCase(" ")]
public void update_should_throw_target_folder_is_blank(string target)
{
Assert.Throws<ArgumentException>(() => mocker.Resolve<UpdateProvider>().Start(target))
Assert.Throws<ArgumentException>(() => Mocker.Resolve<UpdateProvider>().Start(target))
.Message.Should().StartWith("Target folder can not be null or empty");
}
@ -44,7 +39,7 @@ namespace NzbDrone.Update.Test
{
string targetFolder = "c:\\NzbDrone\\";
Assert.Throws<DirectoryNotFoundException>(() => mocker.Resolve<UpdateProvider>().Start(targetFolder))
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<UpdateProvider>().Start(targetFolder))
.Message.Should().StartWith("Target folder doesn't exist");
}
@ -54,15 +49,15 @@ namespace NzbDrone.Update.Test
const string sandboxFolder = @"C:\Temp\NzbDrone_update\nzbdrone";
const string targetFolder = "c:\\NzbDrone\\";
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(c => c.FolderExists(targetFolder))
.Returns(true);
mocker.GetMock<DiskProvider>()
Mocker.GetMock<DiskProvider>()
.Setup(c => c.FolderExists(sandboxFolder))
.Returns(false);
Assert.Throws<DirectoryNotFoundException>(() => mocker.Resolve<UpdateProvider>().Start(targetFolder))
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<UpdateProvider>().Start(targetFolder))
.Message.Should().StartWith("Update folder doesn't exist");
}
}