From 35511a8b7641b85a5cb04b7365629e80f95934ea Mon Sep 17 00:00:00 2001
From: Mark McDowall <markus.mcd5@gmail.com>
Date: Fri, 28 Sep 2012 22:09:07 -0700
Subject: [PATCH] NCrunch works for unit tests

---
 .gitignore                                    |  3 ++-
 NzbDrone.Common.Test/DiskProviderFixture.cs   |  2 +-
 .../NzbDrone.Common.Test.ncrunchproject       | 21 +++++++++++++++++--
 NzbDrone.Common/EnvironmentProvider.cs        |  4 +++-
 .../NzbDrone.Core.Test.ncrunchproject         | 12 +++++++++--
 .../NzbDrone.Web.UI.Automation.ncrunchproject | 18 ++++++++++++++--
 NzbDrone.ncrunchsolution                      |  1 +
 7 files changed, 52 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore
index be082609e..10d2ec7b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,4 +46,5 @@ UpdateLogs/
 NzbDrone.Web/MediaCover
 NzbDrone.fpr
 nzbdrone.log*txt
-_rawPackage_service/
\ No newline at end of file
+_rawPackage_service/
+_NCrunch_*
\ No newline at end of file
diff --git a/NzbDrone.Common.Test/DiskProviderFixture.cs b/NzbDrone.Common.Test/DiskProviderFixture.cs
index c29924494..a4762bbdd 100644
--- a/NzbDrone.Common.Test/DiskProviderFixture.cs
+++ b/NzbDrone.Common.Test/DiskProviderFixture.cs
@@ -62,7 +62,7 @@ namespace NzbDrone.Common.Test
             var targetPath = Path.Combine(BinFolderCopy.FullName, "file.move");
 
             diskProvider.MoveFile(BinFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName, targetPath);
-            diskProvider.MoveFile(BinFolderCopy.GetFiles("*.dll", SearchOption.AllDirectories).First().FullName, targetPath);
+            diskProvider.MoveFile(BinFolderCopy.GetFiles("*.pdb", SearchOption.AllDirectories).First().FullName, targetPath);
 
             File.Exists(targetPath).Should().BeTrue();
         }
diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject b/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject
index 8641d3614..c2e8bc20c 100644
--- a/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject
+++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject
@@ -13,7 +13,24 @@
   <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
   <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
   <DefaultTestTimeout>60000</DefaultTestTimeout>
-  <UseBuildConfiguration />
-  <ProxyProcessPath />
+  <UseBuildConfiguration></UseBuildConfiguration>
+  <ProxyProcessPath></ProxyProcessPath>
   <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
+  <IgnoredTests>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Common.Test.EnviromentProviderTest.ApplicationPath_should_find_root_in_current_folder</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Common.Test.ProcessProviderTests.Should_be_able_to_kill_procces</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Common.Test.ProcessProviderTests.Should_be_able_to_start_process</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Common.Test.ServiceProviderTests.Service_should_be_installed_and_then_uninstalled</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Common.Test.ServiceProviderTests.Should_be_able_to_start_and_stop_service</TestName>
+    </NamedTestSelector>
+  </IgnoredTests>
 </ProjectConfiguration>
\ No newline at end of file
diff --git a/NzbDrone.Common/EnvironmentProvider.cs b/NzbDrone.Common/EnvironmentProvider.cs
index 5a146742c..e080449c0 100644
--- a/NzbDrone.Common/EnvironmentProvider.cs
+++ b/NzbDrone.Common/EnvironmentProvider.cs
@@ -64,7 +64,6 @@ namespace NzbDrone.Common
                 if (!string.IsNullOrWhiteSpace(applicationPath))
                     return applicationPath;
 
-
                 applicationPath = CrawlToRoot(Environment.CurrentDirectory);
                 if (!string.IsNullOrWhiteSpace(applicationPath))
                     return applicationPath;
@@ -83,6 +82,9 @@ namespace NzbDrone.Common
 
         public string CrawlToRoot(string dir)
         {
+            if (String.IsNullOrWhiteSpace(dir))
+                return null;
+
             var directoryInfo = new DirectoryInfo(dir);
 
             while (!IsRoot(directoryInfo))
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject
index 8641d3614..19f185295 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject
@@ -13,7 +13,15 @@
   <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
   <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
   <DefaultTestTimeout>60000</DefaultTestTimeout>
-  <UseBuildConfiguration />
-  <ProxyProcessPath />
+  <UseBuildConfiguration></UseBuildConfiguration>
+  <ProxyProcessPath></ProxyProcessPath>
   <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
+  <IgnoredTests>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Core.Test.ProviderTests.NewznabProviderTest.CheckHostname_should_log_error_and_throw_exception_if_dnsHostname_is_invalid</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Core.Test.Integeration.ServiceIntegerationFixture.should_be_able_to_submit_exceptions</TestName>
+    </NamedTestSelector>
+  </IgnoredTests>
 </ProjectConfiguration>
\ No newline at end of file
diff --git a/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject b/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject
index 8641d3614..53613377d 100644
--- a/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject
+++ b/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject
@@ -13,7 +13,21 @@
   <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
   <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
   <DefaultTestTimeout>60000</DefaultTestTimeout>
-  <UseBuildConfiguration />
-  <ProxyProcessPath />
+  <UseBuildConfiguration></UseBuildConfiguration>
+  <ProxyProcessPath></ProxyProcessPath>
   <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
+  <IgnoredTests>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Web.UI.Automation.BasicPageFixture.HistoryPage</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Web.UI.Automation.BasicPageFixture.HomePage</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Web.UI.Automation.BasicPageFixture.MissingPage</TestName>
+    </NamedTestSelector>
+    <NamedTestSelector>
+      <TestName>NzbDrone.Web.UI.Automation.BasicPageFixture.SettingsPage</TestName>
+    </NamedTestSelector>
+  </IgnoredTests>
 </ProjectConfiguration>
\ No newline at end of file
diff --git a/NzbDrone.ncrunchsolution b/NzbDrone.ncrunchsolution
index ee1975f67..26bb12822 100644
--- a/NzbDrone.ncrunchsolution
+++ b/NzbDrone.ncrunchsolution
@@ -6,6 +6,7 @@
   <FrameworkUtilisationTypeForGallio>UseStaticAnalysis</FrameworkUtilisationTypeForGallio>
   <FrameworkUtilisationTypeForMSpec>UseStaticAnalysis</FrameworkUtilisationTypeForMSpec>
   <FrameworkUtilisationTypeForMSTest>UseStaticAnalysis</FrameworkUtilisationTypeForMSTest>
+  <AdditionalFilesToInclude>NzbDrone.Web\**.*</AdditionalFilesToInclude>
   <EngineModes>Run all tests automatically:BFRydWU=;Run all tests manually:BUZhbHNl;Run impacted tests automatically, others manually (experimental!):CklzSW1wYWN0ZWQ=;Run pinned tests automatically, others manually:CElzUGlubmVk</EngineModes>
   <MetricsExclusionList>
 </MetricsExclusionList>