diff --git a/NzbDrone.App.Test/MonitoringProviderTest.cs b/NzbDrone.App.Test/MonitoringProviderTest.cs index e7277ed3d..ecc3aacd7 100644 --- a/NzbDrone.App.Test/MonitoringProviderTest.cs +++ b/NzbDrone.App.Test/MonitoringProviderTest.cs @@ -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(); + var processMock = Mocker.GetMock(); processMock.Setup(c => c.GetCurrentProcess()) .Returns(Builder.CreateNew().With(c => c.Priority == ProcessPriorityClass.Normal).Build()); processMock.Setup(c => c.GetProcessById(It.IsAny())).Returns((ProcessInfo)null); - var subject = mocker.Resolve(); + var subject = Mocker.Resolve(); //Act diff --git a/NzbDrone.App.Test/RouterTest.cs b/NzbDrone.App.Test/RouterTest.cs index 5c9e50841..e9bf8c2a8 100644 --- a/NzbDrone.App.Test/RouterTest.cs +++ b/NzbDrone.App.Test/RouterTest.cs @@ -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(); + WithStrictMocker(); + var serviceProviderMock = Mocker.GetMock(); serviceProviderMock.Setup(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME)); serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false); - mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); + Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); - mocker.Resolve().Route(ApplicationMode.InstallService); + Mocker.Resolve().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(); + WithStrictMocker(); + var serviceProviderMock = Mocker.GetMock(); serviceProviderMock.Setup(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME)); - mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); + Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true); - mocker.Resolve().Route(ApplicationMode.UninstallService); + Mocker.Resolve().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(); - var appServerProvider = mocker.GetMock(); + WithStrictMocker(); + var consoleProvider = Mocker.GetMock(); + var appServerProvider = Mocker.GetMock(); consoleProvider.Setup(c => c.WaitForClose()); appServerProvider.Setup(c => c.Start()); - mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); + Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); - mocker.Resolve().Route(ApplicationMode.Console); + Mocker.Resolve().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(); - var serviceProvider = mocker.GetMock(); + WithStrictMocker(); + var envMock = Mocker.GetMock(); + var serviceProvider = Mocker.GetMock(); envMock.SetupGet(c => c.IsUserInteractive).Returns(false); serviceProvider.Setup(c => c.Run(It.IsAny())); - mocker.Resolve().Route(applicationMode); + Mocker.Resolve().Route(applicationMode); serviceProvider.Verify(c => c.Run(It.IsAny()), 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(); - var serviceMock = mocker.GetMock(); - mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); + WithStrictMocker(); + var consoleMock = Mocker.GetMock(); + var serviceMock = Mocker.GetMock(); + Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); consoleMock.Setup(c => c.PrintServiceAlreadyExist()); serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true); - mocker.Resolve().Route(ApplicationMode.InstallService); + Mocker.Resolve().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(); - var serviceMock = mocker.GetMock(); - mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); + WithStrictMocker(); + var consoleMock = Mocker.GetMock(); + var serviceMock = Mocker.GetMock(); + Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); consoleMock.Setup(c => c.PrintServiceDoestExist()); serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false); - mocker.Resolve().Route(ApplicationMode.UninstallService); + Mocker.Resolve().Route(ApplicationMode.UninstallService); - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); } } } diff --git a/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/NzbDrone.Common.Test/ConfigFileProviderTest.cs index 39fe8825e..ad861d1b2 100644 --- a/NzbDrone.Common.Test/ConfigFileProviderTest.cs +++ b/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -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().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().LaunchBrowser; diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 9d8658522..e47c64284 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -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() + Mocker.GetMock() .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\" + fileName)); var fakeSettings = Builder.CreateNew().Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); - var mockIndexer = mocker.Resolve(); + var mockIndexer = Mocker.Resolve(); 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() + Mocker.GetMock() .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\newbin_none_english.xml")); - var newzbin = mocker.Resolve(); + var newzbin = Mocker.Resolve(); 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(); + + Mocker.Resolve(); var fakeSettings = Builder.CreateNew().Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); - mocker.GetMock() + Mocker.GetMock() .SetupGet(c => c.NewzbinUsername) .Returns("nzbdrone"); - mocker.GetMock() + Mocker.GetMock() .SetupGet(c => c.NewzbinPassword) .Returns("smartar39865"); - var newzbinProvider = mocker.Resolve(); + var newzbinProvider = Mocker.Resolve(); 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.CreateNew().Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); @@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test .With(c => c.Summary = new TextSyndicationContent(summary)) .Build(); - var result = mocker.Resolve().ParseFeed(fakeRssItem); + var result = Mocker.Resolve().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.CreateNew().Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); @@ -166,7 +166,7 @@ namespace NzbDrone.Core.Test .With(c => c.Summary = new TextSyndicationContent(summary)) .Build(); - var result = mocker.Resolve().ParseFeed(fakeRssItem); + var result = Mocker.Resolve().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.CreateNew().Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); - mocker.Resolve().FetchRss(); + Mocker.Resolve().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() + Mocker.GetMock() .SetupGet(c => c.NzbsOrgUId) .Returns("43516"); - mocker.GetMock() + Mocker.GetMock() .SetupGet(c => c.NzbsOrgHash) .Returns("bc8edb4cc49d4ae440775adec5ac001f"); - mocker.Resolve(); + Mocker.Resolve(); - var result = mocker.Resolve().FetchEpisode(title, season, episode); + var result = Mocker.Resolve().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() + Mocker.GetMock() .SetupGet(c => c.NewzbinUsername) .Returns("nzbdrone"); - mocker.GetMock() + Mocker.GetMock() .SetupGet(c => c.NewzbinPassword) .Returns("smartar39865"); - mocker.Resolve(); + Mocker.Resolve(); - var result = mocker.Resolve().FetchEpisode(title, season, episode); + var result = Mocker.Resolve().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() + Mocker.GetMock() .SetupGet(c => c.NzbMatrixUsername) .Returns(""); - mocker.GetMock() + Mocker.GetMock() .SetupGet(c => c.NzbMatrixApiKey) .Returns(""); - mocker.Resolve(); + Mocker.Resolve(); - var result = mocker.Resolve().FetchEpisode("Simpsons", 21, 23); + var result = Mocker.Resolve().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() + Mocker.GetMock() .SetupGet(c => c.NzbMatrixUsername) .Returns(""); - mocker.GetMock() + Mocker.GetMock() .SetupGet(c => c.NzbMatrixApiKey) .Returns(""); - mocker.Resolve(); + Mocker.Resolve(); - var result = mocker.Resolve().FetchEpisode("Blue Bloods", 1, 19); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml")); //Act - var parseResults = mocker.Resolve().FetchRss(); + var parseResults = Mocker.Resolve().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() + Mocker.GetMock() .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbmatrix.xml")); //Act - var parseResults = mocker.Resolve().FetchRss(); + var parseResults = Mocker.Resolve().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() + Mocker.GetMock() .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsorg.xml")); //Act - var parseResults = mocker.Resolve().FetchRss(); + var parseResults = Mocker.Resolve().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() + Mocker.GetMock() .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbsrus.xml")); //Act - var parseResults = mocker.Resolve().FetchRss(); + var parseResults = Mocker.Resolve().FetchRss(); parseResults.Should().HaveCount(1); parseResults[0].Size.Should().Be(1793148846); diff --git a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs index 8b3e46b46..ab04a8670 100644 --- a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs @@ -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(); - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), Times.Never()); - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), Times.Never()); } @@ -47,22 +48,22 @@ namespace NzbDrone.Core.Test.JobTests var episodes = Builder.CreateListOfSize(1).Build(); - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Start(notification, It.IsAny(), 0)).Verifiable(); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), Times.Never()); - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), Times.Once()); } @@ -74,22 +75,22 @@ namespace NzbDrone.Core.Test.JobTests var episodes = Builder.CreateListOfSize(5).Build(); - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Start(notification, It.IsAny(), 0)).Verifiable(); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), Times.Never()); - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 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() + Mocker.GetMock() .Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Start(notification, It.IsAny(), 0)).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), Times.Never()); - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 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() + Mocker.GetMock() .Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Start(notification, It.IsAny(), It.IsAny())).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList()); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), Times.Once()); - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 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() + Mocker.GetMock() .Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Start(notification, It.IsAny(), It.IsAny())).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Start(notification, It.IsAny(), 0)).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List { 1, 2, 3, 4, 5 }); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), It.IsAny()), Times.Once()); - mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), + Mocker.GetMock().Verify(c => c.Start(notification, It.IsAny(), 0), Times.Exactly(5)); } } diff --git a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs index 0ff6e4b7a..13a6612aa 100644 --- a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs @@ -27,22 +27,22 @@ namespace NzbDrone.Core.Test.JobTests .With(s => s.SeriesId = 12) .Build(); - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetSeries(series.SeriesId)) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Scan(series)) .Returns(new List()); //Act - mocker.Resolve().Start(new ProgressNotification("Test"), series.SeriesId, 0); + Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.GetAllSeries()) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[0])) .Returns(new List()); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[1])) .Returns(new List()); - mocker.Resolve().Start(new ProgressNotification("Test"), 0, 0); + Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.GetAllSeries()) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[0])) .Throws(new InvalidOperationException("Bad Job")); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[1])) .Throws(new InvalidOperationException("Bad Job")); - mocker.Resolve().Start(new ProgressNotification("Test"), 0, 0); + Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.GetAllSeries()) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[0])) .Returns(new List()); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Scan(series[1])) .Returns(new List()); - mocker.Resolve().Start(new ProgressNotification("Test"), 0, 0); + Mocker.Resolve().Start(new ProgressNotification("Test"), 0, 0); - mocker.VerifyAllMocks(); - mocker.GetMock().Verify(s => s.Scan(It.IsAny()), Times.Exactly(2)); + Mocker.VerifyAllMocks(); + Mocker.GetMock().Verify(s => s.Scan(It.IsAny()), Times.Exactly(2)); } } diff --git a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs index ba6446f77..93434eeee 100644 --- a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs @@ -31,53 +31,53 @@ namespace NzbDrone.Core.Test.JobTests var notification = new ProgressNotification("Test"); - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetAllSeries()) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[0].SeriesId, 0)) .Callback(() => series[0].LastDiskSync = DateTime.Now); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[1].SeriesId, 0)) .Callback(() => series[1].LastDiskSync = DateTime.Now); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, It.IsAny(), 0)); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[0].SeriesId, 0)) .Callback(() => series[0].LastInfoSync = DateTime.Now); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[1].SeriesId, 0)) .Callback(() => series[1].LastInfoSync = DateTime.Now); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSeries(series[1].SeriesId)).Returns(series[1]); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSeriesFiles(It.IsAny())).Returns(new List()); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); - mocker.GetMock().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once()); - mocker.GetMock().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once()); + Mocker.GetMock().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once()); + Mocker.GetMock().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once()); - mocker.GetMock().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once()); - mocker.GetMock().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once()); + Mocker.GetMock().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once()); + Mocker.GetMock().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() + Mocker.GetMock() .Setup(p => p.GetAllSeries()) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[0].SeriesId, 0)) .Callback(() => series[0].LastInfoSync = DateTime.Now); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[1].SeriesId, 0)) .Throws(new InvalidOperationException()); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[0].SeriesId, 0)) .Callback(() => series[0].LastDiskSync = DateTime.Now); - mocker.GetMock() + Mocker.GetMock() .Setup(j => j.Start(notification, series[0].SeriesId, 0)); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSeriesFiles(It.IsAny())).Returns(new List()); //Act - mocker.Resolve().Start(notification, 0, 0); + Mocker.Resolve().Start(notification, 0, 0); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); - mocker.GetMock().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once()); - mocker.GetMock().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once()); + Mocker.GetMock().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once()); + Mocker.GetMock().Verify(j => j.Start(notification, series[1].SeriesId, 0), Times.Once()); - mocker.GetMock().Verify(j => j.Start(notification, series[0].SeriesId, 0), Times.Once()); + Mocker.GetMock().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() + WithStrictMocker(); + Mocker.GetMock() .Setup(p => p.GetSeriesFiles(seriesId)) .Returns(new List()); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetSeasons(seriesId)) .Returns(new List { 0, 1, 2, 3, 4 }); - mocker.Resolve().AutoIgnoreSeasons(seriesId); + Mocker.Resolve().AutoIgnoreSeasons(seriesId); - mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, It.IsAny(), It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, It.IsAny(), It.IsAny()), 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() + Mocker.GetMock() .Setup(p => p.GetSeriesFiles(seriesId)) .Returns(episodesFiles); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetSeasons(seriesId)) .Returns(new List { 0, 1, 2 }); - mocker.Resolve().AutoIgnoreSeasons(seriesId); + Mocker.Resolve().AutoIgnoreSeasons(seriesId); - mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny()), Times.Never()); } [Test] @@ -198,21 +198,21 @@ namespace NzbDrone.Core.Test.JobTests episodesFiles[0].SeasonNumber = 1; - var mocker = new AutoMoqer(); + - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetSeriesFiles(seriesId)) .Returns(episodesFiles); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetSeasons(seriesId)) .Returns(new List { 0, 1, 2 }); - mocker.Resolve().AutoIgnoreSeasons(seriesId); + Mocker.Resolve().AutoIgnoreSeasons(seriesId); - mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 0, true), Times.Once()); - mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 1, true), Times.Never()); - mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 0, true), Times.Once()); + Mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 1, true), Times.Never()); + Mocker.GetMock().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny()), Times.Never()); } } diff --git a/NzbDrone.Core.Test/JobTests/SearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SearchJobTest.cs index 6dd2dbf88..288e173d8 100644 --- a/NzbDrone.Core.Test/JobTests/SearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/SearchJobTest.cs @@ -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().Start(new ProgressNotification("Test"), target, 0); + WithStrictMocker(); + Mocker.Resolve().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().Start(new ProgressNotification("Test"), 0, target); + WithStrictMocker(); + Mocker.Resolve().Start(new ProgressNotification("Test"), 0, target); } } } diff --git a/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs index 4cfa03d4b..6c74b4faf 100644 --- a/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs @@ -19,25 +19,25 @@ namespace NzbDrone.Core.Test.JobTests { var seasons = new List { 1, 2, 3, 4, 5 }; - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); var notification = new ProgressNotification("Series Search"); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSeasons(1)).Returns(seasons); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.IsIgnored(It.IsAny(), It.IsAny())).Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.Start(notification, 1, It.IsAny())).Verifiable(); //Act - mocker.Resolve().Start(notification, 1, 0); + Mocker.Resolve().Start(notification, 1, 0); //Assert - mocker.VerifyAllMocks(); - mocker.GetMock().Verify(c => c.Start(notification, 1, It.IsAny()), + Mocker.VerifyAllMocks(); + Mocker.GetMock().Verify(c => c.Start(notification, 1, It.IsAny()), Times.Exactly(seasons.Count)); } @@ -46,19 +46,19 @@ namespace NzbDrone.Core.Test.JobTests { var seasons = new List(); - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); var notification = new ProgressNotification("Series Search"); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSeasons(1)).Returns(seasons); //Act - mocker.Resolve().Start(notification, 1, 0); + Mocker.Resolve().Start(notification, 1, 0); //Assert - mocker.VerifyAllMocks(); - mocker.GetMock().Verify(c => c.Start(notification, 1, It.IsAny()), + Mocker.VerifyAllMocks(); + Mocker.GetMock().Verify(c => c.Start(notification, 1, It.IsAny()), Times.Never()); } diff --git a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs index bc8c0c41a..e6d26a982 100644 --- a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs @@ -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().SetValue(key, value); + Mocker.Resolve().SetValue(key, value); //Assert - mocker.Resolve().GetValue(key, "").Should().Be(value); + Mocker.Resolve().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().GetValue(key, ""); + var result = Mocker.Resolve().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().GetValue(key, value); + var result = Mocker.Resolve().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().SetValue(key, newValue); - var result = mocker.Resolve().GetValue(key, ""); + Mocker.Resolve().SetValue(key, newValue); + var result = Mocker.Resolve().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().SetValue(key, value); - mocker.Resolve().SetValue(key, value); - var result = mocker.Resolve().GetValue(key, ""); + Mocker.Resolve().SetValue(key, value); + Mocker.Resolve().SetValue(key, value); + var result = Mocker.Resolve().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(); + var configProvider = Mocker.Resolve(); var allProperties = typeof(ConfigProvider).GetProperties(); diff --git a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs index 520236346..19a92cb8d 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs @@ -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().FreeDiskSpace(di); + var result = Mocker.Resolve().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) diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs index 70edf3daa..7583b99a4 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs @@ -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() + + Mocker.GetMock() .Setup(c => c.UpdateSeries(It.Is(s => s.LastDiskSync != null))).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetEpisodeBySeries(It.IsAny())) .Returns(new List { new Episode() }); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.FolderExists(It.IsAny())) .Returns(true); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetSeriesFiles(It.IsAny())) .Returns(new List()); - mocker.Resolve().Scan(new Series()); + Mocker.Resolve().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.CreateListOfSize(10).Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.FileExists(It.IsAny())) .Returns(true); //Act - mocker.Resolve().CleanUp(episodes); + Mocker.Resolve().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.CreateListOfSize(10).Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.FileExists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByFileId(It.IsAny())) .Returns(new List()); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.Delete(It.IsAny())); //Act - mocker.Resolve().CleanUp(episodes); + Mocker.Resolve().CleanUp(episodes); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); - mocker.GetMock() + Mocker.GetMock() .Verify(e => e.GetEpisodesByFileId(It.IsAny()), Times.Exactly(10)); - mocker.GetMock() + Mocker.GetMock() .Verify(e => e.Delete(It.IsAny()), 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.CreateListOfSize(10).Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.FileExists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByFileId(It.IsAny())) .Returns(new List { new Episode { EpisodeFileId = 10 }, new Episode { EpisodeFileId = 10 } }); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.UpdateEpisode(It.IsAny())); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.Delete(It.IsAny())); //Act - mocker.Resolve().CleanUp(episodes); + Mocker.Resolve().CleanUp(episodes); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); - mocker.GetMock() + Mocker.GetMock() .Verify(e => e.GetEpisodesByFileId(It.IsAny()), Times.Exactly(10)); - mocker.GetMock() + Mocker.GetMock() .Verify(e => e.UpdateEpisode(It.Is(g=>g.EpisodeFileId == 0)), Times.Exactly(20)); - mocker.GetMock() + Mocker.GetMock() .Verify(e => e.Delete(It.IsAny()), Times.Exactly(10)); - mocker.GetMock() + Mocker.GetMock() .Verify(e => e.Delete(It.IsAny()), 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.CreateNew() .With(s => s.Path = @"C:\Test\TV\SeriesName\") .Build(); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.DeleteOrphaned()) .Returns(0); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.RepairLinks()) .Returns(0); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.FolderExists(series.Path)) .Returns(false); //Act - mocker.Resolve().Scan(series, series.Path); + Mocker.Resolve().Scan(series, series.Path); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); ExceptionVerification.ExcpectedWarns(1); } diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs index f3db56dba..7dcf8a1f7 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs @@ -29,23 +29,23 @@ namespace NzbDrone.Core.Test.ProviderTests var fakeEpisode = Builder.CreateNew().Build(); //Mocks - var mocker = new AutoMoqer(); + - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetSize(newFile)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(new List { fakeEpisode }); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, newFile); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(e => e.GetSize(newFile)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(new List { fakeEpisode }); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, newFile); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(new List { fakeEpisode }); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().ImportFile(fakeSeries, fileName); //Assert - VerifySkipImport(result, mocker); + VerifySkipImport(result, Mocker); } [Test] @@ -124,19 +124,19 @@ namespace NzbDrone.Core.Test.ProviderTests var fakeSeries = Builder.CreateNew().Build(); - var mocker = new AutoMoqer(); + - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())).Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(size).Verifiable(); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().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.CreateNew().Build(); //Mocks - var mocker = new AutoMoqer(); + - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())).Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(size).Verifiable(); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().ImportFile(fakeSeries, fileName); //Assert - VerifySkipImport(result, mocker); + VerifySkipImport(result, Mocker); } [Test] @@ -171,16 +171,16 @@ namespace NzbDrone.Core.Test.ProviderTests var fakeSeries = Builder.CreateNew().Build(); - var mocker = new AutoMoqer(MockBehavior.Strict); - mocker.GetMock() + WithStrictMocker(); + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(true); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().ImportFile(fakeSeries, fileName); //Assert - VerifySkipImport(result, mocker); + VerifySkipImport(result, Mocker); } [Test] @@ -193,24 +193,24 @@ namespace NzbDrone.Core.Test.ProviderTests var fakeSeries = Builder.CreateNew().Build(); //Mocks - var mocker = new AutoMoqer(); - mocker.GetMock() + + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .Setup(e => e.GetSize(fileName)).Returns(90000000000); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetEpisodesByParseResult(It.IsAny(), false)) .Returns(new List()); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(new List { fakeEpisode }); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().ImportFile(fakeSeries, fileName); //Assert - VerifyFileImport(result, mocker, fakeEpisode, 12345); - mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), Times.Once()); + VerifyFileImport(result, Mocker, fakeEpisode, 12345); + Mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), 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() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(fakeEpisodes); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().ImportFile(fakeSeries, fileName); //Assert - VerifyFileImport(result, mocker, fakeEpisodes[0], 12345); - mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), Times.Once()); + VerifyFileImport(result, Mocker, fakeEpisodes[0], 12345); + Mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), 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() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(fakeEpisodes); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(new List { fakeEpisode1, fakeEpisode2 }); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().ImportFile(fakeSeries, fileName); //Assert - VerifyFileImport(result, mocker, fakeEpisode1, 12345); - mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), Times.Exactly(2)); + VerifyFileImport(result, Mocker, fakeEpisode1, 12345); + Mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), Times.Exactly(2)); } [Test] @@ -373,48 +373,48 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); //Mocks - var mocker = new AutoMoqer(); + - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.Exists(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.GetEpisodesByParseResult(It.IsAny(), false)).Returns(new List { fakeEpisode}); //Act - var result = mocker.Resolve().ImportFile(fakeSeries, fileName); + var result = Mocker.Resolve().ImportFile(fakeSeries, fileName); //Assert - VerifyFileImport(result, mocker, fakeEpisode, 12345); - mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), Times.Never()); + VerifyFileImport(result, Mocker, fakeEpisode, 12345); + Mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), 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().Verify(p => p.Add(It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(p => p.Add(It.IsAny()), Times.Once()); //Get the count of episodes linked - var count = mocker.GetMock().Object.GetEpisodesByParseResult(null, false).Count; + var count = Mocker.GetMock().Object.GetEpisodesByParseResult(null, false).Count; - mocker.GetMock().Verify(p => p.UpdateEpisode(It.Is(e => e.EpisodeFileId == result.EpisodeFileId)), Times.Exactly(count)); + Mocker.GetMock().Verify(p => p.UpdateEpisode(It.Is(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().Verify(p => p.Add(It.IsAny()), Times.Never()); - mocker.GetMock().Verify(p => p.UpdateEpisode(It.IsAny()), Times.Never()); - mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(p => p.Add(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(p => p.UpdateEpisode(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(p => p.DeleteFile(It.IsAny()), Times.Never()); } } } diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs index c32448fa2..64410b9c7 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs @@ -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.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() + Mocker.GetMock() .Setup(s => s.IsInQueue(It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.AddByUrl(parseResult.NzbUrl, sabTitle)) .Returns(true); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.GetSabTitle(parseResult)) .Returns(sabTitle); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Add(It.Is(h => h.EpisodeId == 12 && h.SeriesId == 5))); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Add(It.Is(h => h.EpisodeId == 99 && h.SeriesId == 5))); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetEpisodesByParseResult(It.IsAny(), false)).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.MarkEpisodeAsFetched(12)); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.MarkEpisodeAsFetched(99)); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.OnGrab(It.IsAny())); - mocker.Resolve().DownloadReport(parseResult); + Mocker.Resolve().DownloadReport(parseResult); - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs index a0e976afd..f8873b2ed 100644 --- a/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs +++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs @@ -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().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); + Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); //Assert var result = db.Fetch(); @@ -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().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); + Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); //Assert var result = db.Fetch(); @@ -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().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); + Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); //Assert var result = db.Fetch(); @@ -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().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); + Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); //Assert var result = db.Fetch(); @@ -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().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); + Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); //Assert var result = db.Fetch(); diff --git a/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs index 4b37ffa5b..bdbcbaaf8 100644 --- a/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs @@ -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(); + var fakeUdp = Mocker.GetMock(); fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny())).Returns(true); //Act - var result = mocker.Resolve().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address); + var result = Mocker.Resolve().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(); + var fakeUdp = Mocker.GetMock(); fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny())).Returns(false); //Act - var result = mocker.Resolve().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address); + var result = Mocker.Resolve().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(); + var fakeUdp = Mocker.GetMock(); fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny())).Returns(true); //Act - var result = mocker.Resolve().SendAction(address, ActionType.ExecBuiltin, command); + var result = Mocker.Resolve().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(); + var fakeUdp = Mocker.GetMock(); fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny())).Returns(false); //Act - var result = mocker.Resolve().SendAction(address, ActionType.ExecBuiltin, command); + var result = Mocker.Resolve().SendAction(address, ActionType.ExecBuiltin, command); //Assert Assert.AreEqual(false, result); diff --git a/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs index e2c45e60c..a2e89ca7c 100644 --- a/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs @@ -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().Register("localhost", 23053, ""); + Mocker.Resolve().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().TestNotification("localhost", 23053, ""); + Mocker.Resolve().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().SendNotification("Episode Grabbed", "Series Title - 1x05 - Episode Title", "GRAB", "localhost", 23053, ""); + Mocker.Resolve().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().SendNotification("Episode Downloaded", "Series Title - 1x05 - Episode Title", "DOWNLOAD", "localhost", 23053, ""); + Mocker.Resolve().SendNotification("Episode Downloaded", "Series Title - 1x05 - Episode Title", "DOWNLOAD", "localhost", 23053, ""); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs index f8d55e673..8e3b6921c 100644 --- a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs @@ -23,14 +23,14 @@ namespace NzbDrone.Core.Test.ProviderTests //Setup var historyItem = Builder.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().AllItems(); + var result = Mocker.Resolve().AllItems(); //Assert result.Should().HaveSameCount(historyItem); @@ -47,9 +47,9 @@ namespace NzbDrone.Core.Test.ProviderTests var historyItems = Builder.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().AllItemsWithRelationships(); + var result = Mocker.Resolve().AllItemsWithRelationships(); //Assert result.Should().HaveSameCount(historyItems); @@ -75,16 +75,16 @@ namespace NzbDrone.Core.Test.ProviderTests //Setup var historyItem = Builder.CreateListOfSize(10).Build(); - var mocker = new AutoMoqer(); + var db = TestDbHelper.GetEmptyDatabase(); - mocker.SetConstant(db); + Mocker.SetConstant(db); db.InsertMany(historyItem); //Act db.Fetch().Should().HaveCount(10); - mocker.Resolve().Purge(); + Mocker.Resolve().Purge(); //Assert db.Fetch().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().Should().HaveCount(30); - mocker.Resolve().Trim(); + Mocker.Resolve().Trim(); //Assert var result = db.Fetch(); @@ -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().GetBestQualityInHistory(12); + var result = Mocker.Resolve().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.CreateNew() .With(h => h.Quality = QualityTypes.Bluray720p).Build(); db.Insert(history); - mocker.SetConstant(db); + Mocker.SetConstant(db); //Act - var result = mocker.Resolve().GetBestQualityInHistory(history.EpisodeId); + var result = Mocker.Resolve().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.CreateNew().Build(); @@ -176,7 +176,7 @@ namespace NzbDrone.Core.Test.ProviderTests }; //Act - mocker.Resolve().Add(history); + Mocker.Resolve().Add(history); //Assert var storedHistory = db.Fetch(); diff --git a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs index cda54dee0..39ff34cb8 100644 --- a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs @@ -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.InitializeIndexers(new List { mocker.Resolve() }); + var indexerProvider = Mocker.Resolve(); + indexerProvider.InitializeIndexers(new List { Mocker.Resolve() }); 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.InitializeIndexers(new List { mocker.Resolve() }); + var indexerProvider = Mocker.Resolve(); + indexerProvider.InitializeIndexers(new List { Mocker.Resolve() }); var settings = indexerProvider.GetSettings(typeof(MockIndexer)); settings.Enable = false; indexerProvider.SaveSettings(settings); diff --git a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs index bf218c914..04322d2ea 100644 --- a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsAcceptableSizeTest.cs @@ -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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultMulti); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultMulti); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultMulti); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultMulti); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(true); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(true); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(true); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(true); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(true); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().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().Setup(s => s.Get(1)).Returns(qualityType); + Mocker.GetMock().Setup(s => s.Get(1)).Returns(qualityType); - mocker.GetMock().Setup( + Mocker.GetMock().Setup( s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(true); //Act - bool result = mocker.Resolve().IsAcceptableSize(parseResultSingle); + bool result = Mocker.Resolve().IsAcceptableSize(parseResultSingle); //Assert result.Should().BeTrue(); diff --git a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs index 125718c5c..91a39a988 100644 --- a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_IsMonitoredTest.cs @@ -86,74 +86,74 @@ namespace NzbDrone.Core.Test.ProviderTests { series.Monitored = false; - var mocker = new AutoMoqer(MockBehavior.Strict); + WithStrictMocker(); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(series); //Act - var result = mocker.Resolve().IsMonitored(parseResultMulti); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(null); //Act - var result = mocker.Resolve().IsMonitored(parseResultMulti); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(It.IsAny(), true)) .Returns(new List { episode }); parseResultSingle.Series.Should().BeNull(); - var result = mocker.Resolve().IsMonitored(parseResultSingle); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(It.IsAny(), true)) .Returns(new List { episode }); @@ -161,24 +161,24 @@ namespace NzbDrone.Core.Test.ProviderTests parseResultSingle.Series.Should().BeNull(); - var result = mocker.Resolve().IsMonitored(parseResultSingle); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(It.IsAny(), true)) .Returns(new List { episode, episode2 }); @@ -187,24 +187,24 @@ namespace NzbDrone.Core.Test.ProviderTests parseResultMulti.Series.Should().BeNull(); - var result = mocker.Resolve().IsMonitored(parseResultMulti); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(It.IsAny(), true)) .Returns(new List { episode, episode2 }); @@ -213,25 +213,25 @@ namespace NzbDrone.Core.Test.ProviderTests parseResultSingle.Series.Should().BeNull(); - var result = mocker.Resolve().IsMonitored(parseResultMulti); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(It.IsAny(), true)) .Returns(new List { episode, episode2 }); @@ -240,30 +240,30 @@ namespace NzbDrone.Core.Test.ProviderTests parseResultSingle.Series.Should().BeNull(); - var result = mocker.Resolve().IsMonitored(parseResultMulti); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.FindSeries(It.IsAny())) .Returns(series); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(It.IsAny(), true)) .Returns(new List { episode }); episode.Ignored = false; - var result = mocker.Resolve().IsMonitored(parseResultDaily); + var result = Mocker.Resolve().IsMonitored(parseResultDaily); //Assert result.Should().BeTrue(); diff --git a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs index dd3f342de..53c1755e2 100644 --- a/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/InventoryProvider_QualityNeededTest.cs @@ -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().IsQualityNeeded(parseResultMulti); + bool result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(parseResultMulti, true)) .Returns(new List { episode, episode2 }); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) .Returns(new QualityType { MaxSize = 100, MinSize = 0 }); episode.EpisodeFile.Quality = QualityTypes.Bluray720p; //Act - bool result = mocker.Resolve().IsQualityNeeded(parseResultMulti); + bool result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.GetBestQualityInHistory(episode.EpisodeId)) .Returns(new Quality(QualityTypes.DVD, true)); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(parseResultSingle, true)) .Returns(new List { episode }); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) .Returns(new QualityType { MaxSize = 100, MinSize = 0 }); episode.EpisodeFile.Quality = QualityTypes.SDTV; //Act - bool result = mocker.Resolve().IsQualityNeeded(parseResultSingle); + bool result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.GetBestQualityInHistory(episode.EpisodeId)) .Returns(new Quality(QualityTypes.SDTV, true)); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(parseResultSingle, true)) .Returns(new List { episode }); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) .Returns(new QualityType { MaxSize = 100, MinSize = 0 }); episode.EpisodeFile.Quality = QualityTypes.SDTV; //Act - bool result = mocker.Resolve().IsQualityNeeded(parseResultSingle); + bool result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(p => p.GetBestQualityInHistory(episode.EpisodeId)) .Returns(null); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.GetEpisodesByParseResult(parseResultSingle, true)) .Returns(new List { episode }); - mocker.GetMock() + Mocker.GetMock() .Setup(p => p.IsFirstOrLastEpisodeOfSeason(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(false); - mocker.GetMock() + Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) .Returns(new QualityType { MaxSize = 100, MinSize = 0 }); episode.EpisodeFile.Quality = QualityTypes.SDTV; //Act - bool result = mocker.Resolve().IsQualityNeeded(parseResultSingle); + bool result = Mocker.Resolve().IsQualityNeeded(parseResultSingle); //Assert result.Should().BeTrue(); - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); } //Should Download diff --git a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs index 842799d0d..36b1850f4 100644 --- a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs +++ b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTests.cs @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.ProviderTests var secondSeriesFiles = Builder.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().GetSeriesFiles(12); + var result = Mocker.Resolve().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().GetSeasonFiles(12, 1); + var result = Mocker.Resolve().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() + Mocker.GetMock() .Setup(c => c.GetEpisodeBySeries(12)) .Returns(new List()); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.RepairLinks()).Returns(0); - mocker.GetMock() + Mocker.GetMock() .Setup(e => e.DeleteOrphaned()).Returns(0); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.FolderExists(It.IsAny())) .Returns(true); @@ -96,10 +96,10 @@ namespace NzbDrone.Core.Test.ProviderTests .With(s => s.SeriesId = 12).Build(); //Act - mocker.Resolve().Scan(series); + Mocker.Resolve().Scan(series); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); } @@ -120,13 +120,13 @@ namespace NzbDrone.Core.Test.ProviderTests //Setup var episodes = Builder.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().RepairLinks(); + var removedLinks = Mocker.Resolve().RepairLinks(); var result = database.Fetch(); //Assert @@ -142,14 +142,14 @@ namespace NzbDrone.Core.Test.ProviderTests var episodeFiles = Builder.CreateListOfSize(10).Build(); var episodes = Builder.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().DeleteOrphaned(); + Mocker.Resolve().DeleteOrphaned(); var result = database.Fetch(); //Assert @@ -172,11 +172,11 @@ namespace NzbDrone.Core.Test.ProviderTests .With(s => s.SeasonFolder = useSeasonFolder) .Build(); - var mocker = new AutoMoqer(); - mocker.GetMock().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat); + + Mocker.GetMock().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat); //Act - var result = mocker.Resolve().CalculateFilePath(fakeSeries, 1, filename, ".mkv"); + var result = Mocker.Resolve().CalculateFilePath(fakeSeries, 1, filename, ".mkv"); //Assert Assert.AreEqual(expectedPath, result.FullName); @@ -188,13 +188,13 @@ namespace NzbDrone.Core.Test.ProviderTests //Setup var episodeFiles = Builder.CreateListOfSize(10).Build(); - var mocker = new AutoMoqer(); + var database = TestDbHelper.GetEmptyDatabase(true); - mocker.SetConstant(database); + Mocker.SetConstant(database); database.InsertMany(episodeFiles); //Act - mocker.Resolve().Delete(1); + Mocker.Resolve().Delete(1); var result = database.Fetch(); //Assert diff --git a/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs b/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs index 8094ee4e9..6e951b658 100644 --- a/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/MediaFileProvider_GetNewFilenameTest.cs @@ -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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episode }, "South Park", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episode }, "South Park", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episode }, "South Park", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episode }, "South Park", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episode }, "South Park", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episode }, "South Park", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episode }, "South Park", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { 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(); + var fakeConfig = Mocker.GetMock(); 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().GetNewFilename(new List { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV); + string result = Mocker.Resolve().GetNewFilename(new List { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV); //Assert Assert.AreEqual("3x23x24", result); diff --git a/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs index 8fcc180d1..ca8af46ac 100644 --- a/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs @@ -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() + WithStrictMocker(); + + Mocker.GetMock() .Setup(c => c.EpisodesWithFiles()).Returns(episodes); - mocker.GetMock() - .Setup(c => c.GetNewFilename(new List {episodes[0]}, "SeriesTitle", It.IsAny())) + Mocker.GetMock() + .Setup(c => c.GetNewFilename(new List { episodes[0] }, "SeriesTitle", It.IsAny())) .Returns("Title1"); - mocker.GetMock() - .Setup(c => c.GetNewFilename(new List {episodes[1]}, "SeriesTitle", It.IsAny())) + Mocker.GetMock() + .Setup(c => c.GetNewFilename(new List { episodes[1] }, "SeriesTitle", It.IsAny())) .Returns("Title2"); //Act var totalItems = 0; - var misnamedEpisodes = mocker.Resolve().MisnamedFiles(1, 10, out totalItems); + var misnamedEpisodes = Mocker.Resolve().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() + Mocker.GetMock() .Setup(c => c.EpisodesWithFiles()).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[0] }, "SeriesTitle", It.IsAny())) .Returns("New Title 1"); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[1] }, "SeriesTitle", It.IsAny())) .Returns("New Title 2"); //Act var totalItems = 0; - var misnamedEpisodes = mocker.Resolve().MisnamedFiles(1, 10, out totalItems); + var misnamedEpisodes = Mocker.Resolve().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() + Mocker.GetMock() .Setup(c => c.EpisodesWithFiles()).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[0] }, "SeriesTitle", It.IsAny())) .Returns("New Title 1"); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[1] }, "SeriesTitle", It.IsAny())) .Returns("Title2"); //Act var totalItems = 0; - var misnamedEpisodes = mocker.Resolve().MisnamedFiles(1, 10, out totalItems); + var misnamedEpisodes = Mocker.Resolve().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() + Mocker.GetMock() .Setup(c => c.EpisodesWithFiles()).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny())) .Returns("New Title 1"); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[2] }, "SeriesTitle", It.IsAny())) .Returns("Title2"); //Act var totalItems = 0; - var misnamedEpisodes = mocker.Resolve().MisnamedFiles(1, 10, out totalItems); + var misnamedEpisodes = Mocker.Resolve().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() + Mocker.GetMock() .Setup(c => c.EpisodesWithFiles()).Returns(episodes); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny())) .Returns("Title1"); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.GetNewFilename(new List { episodes[2] }, "SeriesTitle", It.IsAny())) .Returns("Title2"); //Act var totalItems = 0; - var misnamedEpisodes = mocker.Resolve().MisnamedFiles(1, 10, out totalItems); + var misnamedEpisodes = Mocker.Resolve().MisnamedFiles(1, 10, out totalItems); //Assert misnamedEpisodes.Should().HaveCount(0); diff --git a/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs index ed56ef683..5dc19c2a5 100644 --- a/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs @@ -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().Save(newznab); + var result = Mocker.Resolve().Save(newznab); //Assert db.Single(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().Save(newznab); + var result = Mocker.Resolve().Save(newznab); //Assert db.Single(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().Save(newznab); + var result = Mocker.Resolve().Save(newznab); //Assert db.Single(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().Save(newznab); + var result = Mocker.Resolve().Save(newznab); //Assert db.Single(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().SaveAll(definitions); + Mocker.Resolve().SaveAll(definitions); //Assert db.Fetch().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().Enabled(); + var result = Mocker.Resolve().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().All(); + var result = Mocker.Resolve().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().Delete(1); + Mocker.Resolve().Delete(1); //Assert var result = db.Fetch(); @@ -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().InitializeNewznabIndexers(definitions); + Mocker.Resolve().InitializeNewznabIndexers(definitions); //Assert var result = db.Fetch(); @@ -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().InitializeNewznabIndexers(definitions); + Mocker.Resolve().InitializeNewznabIndexers(definitions); //Assert var result = db.Fetch(); diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadProviderFixture.cs index f39e5e7ba..57993f73f 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadProviderFixture.cs @@ -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().ProcessDownload(droppedFolder); + Mocker.Resolve().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().Setup(s => s.FindSeries(It.IsAny())).Returns(null).Verifiable(); - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null).Verifiable(); + Mocker.Resolve().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().Setup(s => s.FindSeries("office")).Returns(null).Verifiable(); + Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(null).Verifiable(); //Act - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.Resolve().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().Setup(s => s.FindSeries("office")).Returns(null); - mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); + Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(null); + Mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.Resolve().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().Setup(s => s.FindSeries("office")).Returns(fakeSeries); - mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(new List()); - mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); - mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes()); + Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(new List()); + Mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); + Mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes()); - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.Resolve().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().Setup(s => s.FindSeries("office")).Returns(fakeSeries); - mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); - mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes()); - mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); - mocker.GetMock().Setup(s => s.MoveEpisodeFile(It.IsAny(), true)).Returns(true); + Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder)); + Mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes()); + Mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); + Mocker.GetMock().Setup(s => s.MoveEpisodeFile(It.IsAny(), true)).Returns(true); - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.Resolve().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().Setup(s => s.FindSeries(It.IsAny())).Returns(null); - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null); + Mocker.Resolve().ProcessDownload(droppedFolder); //Assert - mocker.VerifyAllMocks(); - mocker.GetMock().Verify(c => c.MoveDirectory(It.IsAny(), It.IsAny()), Times.Never()); + Mocker.VerifyAllMocks(); + Mocker.GetMock().Verify(c => c.MoveDirectory(It.IsAny(), It.IsAny()), 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().Setup(s => s.FindSeries(It.IsAny())).Returns(null); + Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(null); //Act - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.Resolve().ProcessDownload(droppedFolder); //Assert - mocker.VerifyAllMocks(); - mocker.GetMock().Verify(c => c.MoveDirectory(droppedFolder.FullName, taggedFolder), Times.Once()); + Mocker.VerifyAllMocks(); + Mocker.GetMock().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.CreateNew() @@ -207,24 +203,22 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests .With(f => f.SeriesId = fakeSeries.SeriesId) .Build().ToList(); - mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(fakeSeries); - mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); - mocker.GetMock().Setup(s => s.MoveEpisodeFile(It.IsAny(), true)).Returns(true); - mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes()); - mocker.GetMock().Setup(s => s.DeleteFolder(droppedFolder.FullName, true)); + Mocker.GetMock().Setup(s => s.FindSeries("office")).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); + Mocker.GetMock().Setup(s => s.MoveEpisodeFile(It.IsAny(), true)).Returns(true); + Mocker.GetMock().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes()); + Mocker.GetMock().Setup(s => s.DeleteFolder(droppedFolder.FullName, true)); //Act - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.Resolve().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.CreateNew() @@ -233,16 +227,16 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests var fakeEpisodeFiles = Builder.CreateListOfSize(2) .Build().ToList(); - mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(fakeSeries); - mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); + Mocker.GetMock().Setup(s => s.FindSeries(It.IsAny())).Returns(fakeSeries); + Mocker.GetMock().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles); //Act - mocker.Resolve().ProcessDownload(droppedFolder); + Mocker.Resolve().ProcessDownload(droppedFolder); //Assert - mocker.GetMock().Verify(c => c.MoveEpisodeFile(It.IsAny(), true), + Mocker.GetMock().Verify(c => c.MoveEpisodeFile(It.IsAny(), true), Times.Exactly(fakeEpisodeFiles.Count)); - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); } diff --git a/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs index cc33d09cc..a6501c3af 100644 --- a/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs @@ -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().Verify(_apiKey); + var result = Mocker.Resolve().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().Verify(_badApiKey); + var result = Mocker.Resolve().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().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey); + var result = Mocker.Resolve().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().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _badApiKey); + var result = Mocker.Resolve().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().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (High)", _apiKey, NotificationPriority.High); + var result = Mocker.Resolve().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().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (VeryLow)", _apiKey, NotificationPriority.VeryLow); + var result = Mocker.Resolve().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().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey, NotificationPriority.Normal, "http://www.nzbdrone.com"); + var result = Mocker.Resolve().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().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _apiKey2); + var result = Mocker.Resolve().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().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _badApiKey); + var result = Mocker.Resolve().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _badApiKey); //Assert result.Should().BeTrue(); diff --git a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs index eba52ba5b..f9fc4e000 100644 --- a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs @@ -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().SetupDefault(); + Mocker.Resolve().SetupDefault(); //Assert - var types = mocker.Resolve().All(); + var types = Mocker.Resolve().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.CreateNew() .Build(); @@ -51,10 +51,10 @@ namespace NzbDrone.Core.Test.ProviderTests db.Insert(fakeQualityType); //Act - mocker.Resolve().SetupDefault(); + Mocker.Resolve().SetupDefault(); //Assert - var types = mocker.Resolve().All(); + var types = Mocker.Resolve().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.CreateListOfSize(6) .Build(); @@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.ProviderTests db.InsertMany(fakeQualityTypes); //Act - var result = mocker.Resolve().GetList(ids); + var result = Mocker.Resolve().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.CreateListOfSize(6) .Build(); @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.ProviderTests db.InsertMany(fakeQualityTypes); //Act - var result = mocker.Resolve().GetList(ids); + var result = Mocker.Resolve().GetList(ids); //Assert result.Should().HaveCount(ids.Count); diff --git a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs index a1c03bbb3..ffd1f387a 100644 --- a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs @@ -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() + //Mocker.GetMock() // .Setup(f => f.All()) // .Returns(sonicRepo.All); //Act - var result = mocker.Resolve().GetAll(); + var result = Mocker.Resolve().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(); + var rootDirProvider = Mocker.Resolve(); 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(); + var rootDirProvider = Mocker.Resolve(); 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(); + var rootDirProvider = Mocker.Resolve(); 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(MockBehavior.Strict) + + Mocker.GetMock(MockBehavior.Strict) .Setup(m => m.FolderExists(path)).Returns(false); - var result = mocker.Resolve().GetUnmappedFolders(path); + var result = Mocker.Resolve().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().GetUnmappedFolders(""); + + Mocker.Resolve().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().Add(new RootDir { Id = 0, Path = path }); + + Mocker.Resolve().Add(new RootDir { Id = 0, Path = path }); } } diff --git a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs index 29dbb0bea..c724fff7e 100644 --- a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs @@ -36,9 +36,9 @@ namespace NzbDrone.Core.Test.ProviderTests const string category = "tv"; - var mocker = new AutoMoqer(); + - var fakeConfig = mocker.GetMock(); + var fakeConfig = Mocker.GetMock(); 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(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .Setup( s => s.DownloadString( @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.ProviderTests .Returns("ok"); //Act - bool result = mocker.Resolve().AddByUrl( + bool result = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); 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(MockBehavior.Strict) + Mocker.GetMock(MockBehavior.Strict) .Setup( s => s.DownloadString( @@ -109,7 +109,7 @@ namespace NzbDrone.Core.Test.ProviderTests .Returns("ok"); //Act - bool result = mocker.Resolve().AddByUrl( + bool result = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); 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() + Mocker.GetMock() .Setup(s => s.DownloadString(It.IsAny())) .Returns("error"); //Act - var sabProvider = mocker.Resolve(); + var sabProvider = Mocker.Resolve(); 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(); + var fakeConfig = Mocker.GetMock(); 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(MockBehavior.Strict) + Mocker.GetMock(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().IsInQueue("Ubuntu Test"); + bool result = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); 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(MockBehavior.Strict) + Mocker.GetMock(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().IsInQueue(String.Empty); + bool result = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); 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(MockBehavior.Strict) + Mocker.GetMock(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().IsInQueue(String.Empty); + Mocker.Resolve().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.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().GetSabTitle(parsResult); + var actual = Mocker.Resolve().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.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().GetSabTitle(parsResult); + var actual = Mocker.Resolve().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.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().GetSabTitle(parsResult); + var actual = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); 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().AddByUrl( + bool result = Mocker.Resolve().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(MockBehavior.Strict) + Mocker.GetMock(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().GetCategories(host, port, apikey, username, password); + var result = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); 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(MockBehavior.Strict) + Mocker.GetMock(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().GetCategories(); + var result = Mocker.Resolve().GetCategories(); //Assert result.Should().NotBeNull(); diff --git a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs index 8774948a1..a400776ba 100644 --- a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs @@ -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().GetSceneName(fakeMap.SeriesId); + var sceneName = Mocker.Resolve().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().GetSeriesId(fakeMap.CleanTitle); + var seriesId = Mocker.Resolve().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().GetSceneName(54321); + var sceneName = Mocker.Resolve().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().GetSeriesId("notlaworder"); + var seriesId = Mocker.Resolve().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().GetSceneName(fakeMap.SeriesId); + var sceneName = Mocker.Resolve().GetSceneName(fakeMap.SeriesId); //Assert Assert.AreEqual(fakeMap.SceneName, sceneName); diff --git a/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs index c9af6fb99..3eb840579 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs @@ -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().Yesterday(); + var result = Mocker.Resolve().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().Today(); + var result = Mocker.Resolve().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().Tomorrow(); + var result = Mocker.Resolve().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().Week(); + var result = Mocker.Resolve().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().Yesterday(); + var result = Mocker.Resolve().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().Today(); + var result = Mocker.Resolve().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().Tomorrow(); + var result = Mocker.Resolve().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().Week(); + var result = Mocker.Resolve().Week(); //Assert result.Should().HaveCount(1); diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs index 6ca9d4718..70ae88a02 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs @@ -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().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/"); - _mocker.Resolve(); + Mocker.GetMock().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/"); + Mocker.Resolve(); } [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().SetupGet(c => c.Version).Returns(new Version(currentVersion)); + Mocker.GetMock().SetupGet(c => c.Version).Returns(new Version(currentVersion)); - var updatePackage = _mocker.Resolve().GetAvilableUpdate(); + var updatePackage = Mocker.Resolve().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().SetupGet(c => c.Version).Returns(_latestsTestVersion); + Mocker.GetMock().SetupGet(c => c.Version).Returns(_latestsTestVersion); - var updatePackage = _mocker.Resolve().GetAvilableUpdate(); + var updatePackage = Mocker.Resolve().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().SetupGet(c => c.Version).Returns(new Version(currentVersion)); + Mocker.GetMock().SetupGet(c => c.Version).Returns(new Version(currentVersion)); - var updatePackage = _mocker.Resolve().GetAvilableUpdate(); + var updatePackage = Mocker.Resolve().GetAvilableUpdate(); updatePackage.Should().NotBeNull(); updatePackage.Version.Should().Be(_latestsTestVersion); diff --git a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs index c1c343264..2672bd049 100644 --- a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs @@ -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().CheckForJsonError(response); + var result = Mocker.Resolve().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().CheckForJsonError(response); + var result = Mocker.Resolve().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().CheckForJsonError(reposnse); + var result = Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny())) .Returns(message); //Act - var result = mocker.Resolve().GetJsonVersion("localhost:8080", "xbmc", "xbmc"); + var result = Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny())) .Returns(message); //Act - var result = mocker.Resolve().GetJsonVersion("localhost:8080", "xbmc", "xbmc"); + var result = Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny())) .Returns(message); //Act - var result = mocker.Resolve().GetActivePlayers("localhost:8080", "xbmc", "xbmc"); + var result = Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.PostCommand("localhost:8080", "xbmc", "xbmc", It.IsAny())) .Returns(message); //Act - var result = mocker.Resolve().GetTvShowsJson("localhost:8080", "xbmc", "xbmc"); + var result = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080"); - //var fakeUdpProvider = mocker.GetMock(); - var fakeEventClient = mocker.GetMock(); + //var fakeUdpProvider = Mocker.GetMock(); + var fakeEventClient = Mocker.GetMock(); fakeEventClient.Setup(s => s.SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", "localhost")).Returns(true); //Act - mocker.Resolve().Notify(header, message); + Mocker.Resolve().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(); - var fakeHttp = mocker.GetMock(); + //var fakeUdpProvider = Mocker.GetMock(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.DownloadString(url, username, password)).Returns("Ok\n"); //Act - var result = mocker.Resolve().SendCommand(host, command, username, username); + var result = Mocker.Resolve().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 = @"smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/"; @@ -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(); - var fakeHttp = mocker.GetMock(); + //var fakeUdpProvider = Mocker.GetMock(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.DownloadString(setResponseUrl, username, password)).Returns("OK"); fakeHttp.Setup(s => s.DownloadString(resetResponseUrl, username, password)).Returns(@"
  • 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().GetXbmcSeriesPath(host, 79488, username, username); + var result = Mocker.Resolve().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 = @""; @@ -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(); - var fakeHttp = mocker.GetMock(); + //var fakeUdpProvider = Mocker.GetMock(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.DownloadString(setResponseUrl, username, password)).Returns("OK"); fakeHttp.Setup(s => s.DownloadString(resetResponseUrl, username, password)).Returns(@"
  • 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().GetXbmcSeriesPath(host, 79488, username, username); + var result = Mocker.Resolve().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 = @"smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/"; @@ -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(); - var fakeHttp = mocker.GetMock(); + //var fakeUdpProvider = Mocker.GetMock(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.DownloadString(setResponseUrl, username, password)).Returns("OK"); fakeHttp.Setup(s => s.DownloadString(resetResponseUrl, username, password)).Returns(@"
  • 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().GetXbmcSeriesPath(host, 79488, username, username); + var result = Mocker.Resolve().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(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080"); - var fakeEventClient = mocker.GetMock(); + var fakeEventClient = Mocker.GetMock(); fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(CleanLibrary(video))")).Returns(true); //Act - mocker.Resolve().Clean(); + Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.DownloadString(queryUrl, username, password)).Returns(queryResult); fakeHttp.Setup(s => s.DownloadString(url, username, password)); //Act - mocker.Resolve().UpdateWithHttp(fakeSeries, host, username, password); + Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.DownloadString(queryUrl, username, password)).Returns(queryResult); fakeHttp.Setup(s => s.DownloadString(url, username, password)); //Act - mocker.Resolve().UpdateWithHttp(fakeSeries, host, username, password); + Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.PostCommand(host, username, password, serializedQuery)) .Returns(tvshows); - var fakeEventClient = mocker.GetMock(); + var fakeEventClient = Mocker.GetMock(); fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video,smb://HOMESERVER/TV/30 Rock/))")); //Act - mocker.Resolve().UpdateWithJson(fakeSeries, host, username, password); + Mocker.Resolve().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(); + var fakeHttp = Mocker.GetMock(); fakeHttp.Setup(s => s.PostCommand(host, username, password, serializedQuery)) .Returns(tvshows); - var fakeEventClient = mocker.GetMock(); + var fakeEventClient = Mocker.GetMock(); fakeEventClient.Setup(s => s.SendAction("localhost", ActionType.ExecBuiltin, "ExecBuiltIn(UpdateLibrary(video))")); //Act - mocker.Resolve().UpdateWithJson(fakeSeries, host, username, password); + Mocker.Resolve().UpdateWithJson(fakeSeries, host, username, password); //Assert - mocker.VerifyAllMocks(); + Mocker.VerifyAllMocks(); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs index 834d79b10..76f5066d9 100644 --- a/NzbDrone.Core.Test/QualityProfileTest.cs +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -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().Update(currentProfile); + Mocker.Resolve().Update(currentProfile); - var updated = mocker.Resolve().Get(currentProfile.QualityProfileId); + var updated = Mocker.Resolve().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().SetupDefaultProfiles(); + Mocker.Resolve().SetupDefaultProfiles(); //Assert - var profiles = mocker.Resolve().All(); + var profiles = Mocker.Resolve().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.CreateNew().Build(); //Act - mocker.Resolve().Add(fakeProfile); - mocker.Resolve().SetupDefaultProfiles(); + Mocker.Resolve().Add(fakeProfile); + Mocker.Resolve().SetupDefaultProfiles(); //Assert - var profiles = mocker.Resolve().All(); + var profiles = Mocker.Resolve().All(); profiles.Should().HaveCount(1); diff --git a/NzbDrone.Core.Test/dbBenchmark.cs b/NzbDrone.Core.Test/dbBenchmark.cs index b8c749452..2b0161461 100644 --- a/NzbDrone.Core.Test/dbBenchmark.cs +++ b/NzbDrone.Core.Test/dbBenchmark.cs @@ -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(); + + Mocker.SetConstant(db); + Mocker.Resolve(); - var epProvider = mocker.Resolve(); + var epProvider = Mocker.Resolve(); 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(); + + Mocker.SetConstant(db); + Mocker.Resolve(); - var epProvider = mocker.Resolve(); + var epProvider = Mocker.Resolve(); 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(); - mocker.Resolve(); - var mediaProvider = mocker.Resolve(); + + Mocker.SetConstant(db); + Mocker.Resolve(); + Mocker.Resolve(); + var mediaProvider = Mocker.Resolve(); 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(); - mocker.Resolve(); - var mediaProvider = mocker.Resolve(); + + Mocker.SetConstant(db); + Mocker.Resolve(); + Mocker.Resolve(); + var mediaProvider = Mocker.Resolve(); 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(); + + Mocker.SetConstant(db); + var provider = Mocker.Resolve(); Thread.Sleep(1000); diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index 8c43ca9a5..72d0bf571 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -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); } diff --git a/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs b/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs index ffe62626e..2c7caca3a 100644 --- a/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs +++ b/NzbDrone.Update.Test/UpdateProviderVerifyFixture.cs @@ -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() + Mocker.GetMock() .Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\"); - mocker.GetMock() + Mocker.GetMock() .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(() => mocker.Resolve().Start(target)) + Assert.Throws(() => Mocker.Resolve().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(() => mocker.Resolve().Start(targetFolder)) + Assert.Throws(() => Mocker.Resolve().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() + Mocker.GetMock() .Setup(c => c.FolderExists(targetFolder)) .Returns(true); - mocker.GetMock() + Mocker.GetMock() .Setup(c => c.FolderExists(sandboxFolder)) .Returns(false); - Assert.Throws(() => mocker.Resolve().Start(targetFolder)) + Assert.Throws(() => Mocker.Resolve().Start(targetFolder)) .Message.Should().StartWith("Update folder doesn't exist"); } }