diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleApplication.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleApplication.cs index 5eb4586197..43ebbdb8e1 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleApplication.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleApplication.cs @@ -82,7 +82,9 @@ namespace ICSharpCode.UnitTesting if (ProjectUsesDotnet20Runtime(project)) { exe += "-dotnet2"; } - if (IsPlatformTarget32Bit(project)) { + // As SharpDevelop can't debug 64-bit applications yet, use + // 32-bit NUnit even for AnyCPU test projects. + if (IsPlatformTarget32BitOrAnyCPU(project)) { exe += "-x86"; } exe += ".exe"; @@ -234,14 +236,15 @@ namespace ICSharpCode.UnitTesting } /// - /// Checks that the project's PlatformTarget is x86 for the active configuration. + /// Checks that the project's PlatformTarget is x32 for the active configuration. /// - bool IsPlatformTarget32Bit(IProject project) + bool IsPlatformTarget32BitOrAnyCPU(IProject project) { MSBuildBasedProject msbuildProject = project as MSBuildBasedProject; if (msbuildProject != null) { string platformTarget = msbuildProject.GetEvaluatedProperty("PlatformTarget"); - return String.Compare(platformTarget, "x86", true) == 0; + return String.Equals(platformTarget, "x86", StringComparison.OrdinalIgnoreCase) + || String.Equals(platformTarget, "AnyCPU", StringComparison.OrdinalIgnoreCase); } return false; } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleExeSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleExeSelectedTestFixture.cs index d739c2454a..027bc5055d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleExeSelectedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleExeSelectedTestFixture.cs @@ -11,7 +11,7 @@ using UnitTesting.Tests.Utils; namespace UnitTesting.Tests.Frameworks { /// - /// If the project explicitly targets 32 bit (x86) architecture then nunit-console-x86.exe should be + /// If the project explicitly targets 32 bit (x86) architecture then nunit-console-x86.exe should be /// used. Otherwise the normal nunit-console.exe is used. /// [TestFixture] @@ -52,7 +52,8 @@ namespace UnitTesting.Tests.Frameworks SelectedTests selectedTests = new SelectedTests(project); NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); - Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2.exe", app.FileName); + // We use 32-bit NUnit to test AnyCPU projects because the debugger doesn't support 64-bit + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2-x86.exe", app.FileName); } [Test] @@ -64,6 +65,35 @@ namespace UnitTesting.Tests.Frameworks project.SetProperty("PlatformTarget", "AnyCPU"); project.SetProperty("TargetFrameworkVersion", "v4.5"); + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + // We use 32-bit NUnit to test AnyCPU projects because the debugger doesn't support 64-bit + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", app.FileName); + } + + [Test] + public void TargetCpuX64Dotnet2() + { + MockCSharpProject project = new MockCSharpProject(); + project.ActiveConfiguration = "Debug"; + project.ActivePlatform = "AnyCPU"; + project.SetProperty("PlatformTarget", "x64"); + project.SetProperty("TargetFrameworkVersion", "v3.5"); + + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2.exe", app.FileName); + } + + [Test] + public void TargetCpuX64Dotnet45() + { + MockCSharpProject project = new MockCSharpProject(); + project.ActiveConfiguration = "Debug"; + project.ActivePlatform = "AnyCPU"; + project.SetProperty("PlatformTarget", "x64"); + project.SetProperty("TargetFrameworkVersion", "v4.5"); + SelectedTests selectedTests = new SelectedTests(project); NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", app.FileName); @@ -90,10 +120,10 @@ namespace UnitTesting.Tests.Frameworks project.ActiveConfiguration = "Debug"; project.ActivePlatform = "AnyCPU"; project.SetProperty("PlatformTarget", "x86"); - + SelectedTests selectedTests = new SelectedTests(project); NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); - Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", app.FileName); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", app.FileName); } [Test] @@ -104,7 +134,7 @@ namespace UnitTesting.Tests.Frameworks NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); Assert.AreEqual(project.GetType().BaseType, typeof(AbstractProject), "MissingProject should be derived from AbstractProject."); - Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", app.FileName); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", app.FileName); } } }