From 1233089ee41ec45cd1964a5133d6b0f3043990f7 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Wed, 16 Nov 2011 22:40:54 -0800 Subject: [PATCH] Even more faster tests. --- NzbDrone.Common.Test/WebClientTests.cs | 6 ++-- NzbDrone.Core.Test/CentralDispatchFixture.cs | 34 ++++++++----------- .../JobProviderTests/JobProviderFixture.cs | 2 +- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/NzbDrone.Common.Test/WebClientTests.cs b/NzbDrone.Common.Test/WebClientTests.cs index f515ef941..055ee38b5 100644 --- a/NzbDrone.Common.Test/WebClientTests.cs +++ b/NzbDrone.Common.Test/WebClientTests.cs @@ -9,12 +9,12 @@ namespace NzbDrone.Common.Test public class WebClientTests : TestBase { [Test] - public void DownloadString_should_be_able_to_download_jquery() + public void DownloadString_should_be_able_to_dowload_text_file() { - var jquery = new WebClientProvider().DownloadString("http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"); + var jquery = new WebClientProvider().DownloadString("http://www.google.com/robots.txt"); jquery.Should().NotBeBlank(); - jquery.Should().Contain("function(a,b)"); + jquery.Should().Contain("Sitemap"); } [TestCase("")] diff --git a/NzbDrone.Core.Test/CentralDispatchFixture.cs b/NzbDrone.Core.Test/CentralDispatchFixture.cs index 77d867e1d..5fe8968bf 100644 --- a/NzbDrone.Core.Test/CentralDispatchFixture.cs +++ b/NzbDrone.Core.Test/CentralDispatchFixture.cs @@ -21,18 +21,20 @@ namespace NzbDrone.Core.Test readonly IList indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).ToList(); readonly IList jobs = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IJob))).ToList(); - private CentralDispatch centralDispatch; + private IKernel kernel; - [SetUp] - public void Setup() + public CentralDispatchFixture() { - centralDispatch = new CentralDispatch(); + InitLogging(); + kernel = new CentralDispatch().Kernel; + WebTimer.Stop(); } [Test] public void InitAppTest() { - centralDispatch.Kernel.Should().NotBeNull(); + kernel.Should().NotBeNull(); + } [Test] @@ -45,7 +47,7 @@ namespace NzbDrone.Core.Test foreach (var provider in providers) { Console.WriteLine("Resolving " + provider.Name); - centralDispatch.Kernel.Get(provider).Should().NotBeNull(); + kernel.Get(provider).Should().NotBeNull(); } } @@ -55,7 +57,7 @@ namespace NzbDrone.Core.Test { //Assert - var registeredJobs = centralDispatch.Kernel.GetAll(); + var registeredJobs = kernel.GetAll(); jobs.Should().NotBeEmpty(); @@ -68,7 +70,7 @@ namespace NzbDrone.Core.Test { //Assert - var registeredIndexers = centralDispatch.Kernel.GetAll(); + var registeredIndexers = kernel.GetAll(); indexers.Should().NotBeEmpty(); @@ -79,35 +81,29 @@ namespace NzbDrone.Core.Test [Test] public void jobs_are_initialized() { - centralDispatch.Kernel.Get().All().Should().HaveSameCount(jobs); + kernel.Get().All().Should().HaveSameCount(jobs); } [Test] public void indexers_are_initialized() { - centralDispatch.Kernel.Get().All().Should().HaveSameCount(indexers); + kernel.Get().All().Should().HaveSameCount(indexers); } [Test] public void quality_profile_initialized() { - centralDispatch.Kernel.Get().All().Should().HaveCount(2); + kernel.Get().All().Should().HaveCount(2); } [Test] public void JobProvider_should_be_singletone() { - var first = centralDispatch.Kernel.Get(); - var second = centralDispatch.Kernel.Get(); + var first = kernel.Get(); + var second = kernel.Get(); first.Should().BeSameAs(second); } - [TearDown] - public void TearDownBase() - { - WebTimer.Stop(); - - } } } diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs index 4ff401b36..263e8b35d 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests while (stopWatch.IsRunning) { - Thread.Sleep(100); + Thread.Sleep(10); } }