diff options
author | Mike Krüger <mkrueger@novell.com> | 2009-09-02 15:54:12 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2009-09-02 15:54:12 +0400 |
commit | 0013e735a3179213e730ec8fc430913b4ddc2df4 (patch) | |
tree | 1be058f6febc7592f7658d53ce79d4ab9fe68a65 /main/tests | |
parent | 97489fe7c326ffe3267ecd293c834a86dc7124d8 (diff) |
* MonoDevelop.Refactoring/ExtractMethodTests.cs: Added some more
complex test cases.
* TestBase.cs: Handled unlikely error in addin configuration.
svn path=/trunk/monodevelop/; revision=141122
Diffstat (limited to 'main/tests')
-rw-r--r-- | main/tests/UnitTests/ChangeLog | 7 | ||||
-rw-r--r-- | main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs | 77 | ||||
-rw-r--r-- | main/tests/UnitTests/TestBase.cs | 37 |
3 files changed, 112 insertions, 9 deletions
diff --git a/main/tests/UnitTests/ChangeLog b/main/tests/UnitTests/ChangeLog index d66e23e3f8..37bf96f016 100644 --- a/main/tests/UnitTests/ChangeLog +++ b/main/tests/UnitTests/ChangeLog @@ -1,3 +1,10 @@ +2009-09-02 Mike Krüger <mkrueger@novell.com> + + * MonoDevelop.Refactoring/ExtractMethodTests.cs: Added some + more complex test cases. + + * TestBase.cs: Handled unlikely error in addin configuration. + 2009-08-31 Mike Krüger <mkrueger@novell.com> * MonoDevelop.Refactoring/DeclareLocalTests.cs: Added declare diff --git a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs index d5bf947a9f..f8e8ea2d75 100644 --- a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs +++ b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs @@ -295,6 +295,83 @@ namespace MonoDevelop.Refactoring.Tests "); } + [Test()] + public void ExtractMethodMultiVariableTest () + { + TestExtractMethod (@"class TestClass +{ + int member; + void TestMethod () + { + int i = 5, j = 10, k; + <- + j = i + j; + k = j + member; + -> + Console.WriteLine (k); + } +} +", @"class TestClass +{ + int member; + void TestMethod () + { + int i = 5, j = 10, k; + NewMethod (i, ref j, out k); + Console.WriteLine (k); + } + + void NewMethod (int i, ref int j, out int k) + { + j = i + j; + k = j + member; + } +} +"); + } + + [Test()] + public void ExtractMethodMultiVariableWithLocalReturnVariableTest () + { + TestExtractMethod (@"class TestClass +{ + int member; + void TestMethod () + { + int i = 5, j = 10, k; + <- + int test; + j = i + j; + k = j + member; + test = i + j + k; + -> + Console.WriteLine (test); + } +} +", @"class TestClass +{ + int member; + void TestMethod () + { + int i = 5, j = 10, k; + int test; + NewMethod (i, ref j, out k, out test); + Console.WriteLine (test); + } + + void NewMethod (int i, ref int j, out int k, out int test) + { + j = i + j; + k = j + member; + test = i + j + k; + } +} +"); + } + + + + } }
\ No newline at end of file diff --git a/main/tests/UnitTests/TestBase.cs b/main/tests/UnitTests/TestBase.cs index 6767e05e35..37abe5976d 100644 --- a/main/tests/UnitTests/TestBase.cs +++ b/main/tests/UnitTests/TestBase.cs @@ -38,21 +38,40 @@ namespace UnitTests { static bool firstRun = true; + [TestFixtureSetUp] public virtual void Setup () { if (firstRun) { - firstRun = false; - Util.ClearTmpDir (); - Environment.SetEnvironmentVariable ("MONO_ADDINS_REGISTRY", Path.Combine (Util.TestsRootDir, "config")); - Environment.SetEnvironmentVariable ("XDG_CONFIG_HOME", Path.Combine (Util.TestsRootDir, "config")); - Runtime.Initialize (true); - Gtk.Application.Init (); - ProjectDomService.TrackFileChanges = true; - DesktopService.Initialize (); - MonoDevelop.Projects.Services.ProjectService.DefaultTargetFramework = Runtime.SystemAssemblyService.GetTargetFramework ("2.0"); + string rootDir = Path.Combine (Util.TestsRootDir, "config"); + try { + firstRun = false; + InternalSetup (rootDir); + } catch (Exception) { + // if we encounter an error, try to re create the configuration directory + // (This takes much time, therfore it's only done when initialization fails) + try { + if (Directory.Exists (rootDir)) + Directory.Delete (rootDir, true); + InternalSetup (rootDir); + } catch (Exception) { + } + } } } + + static void InternalSetup (string rootDir) + { + Util.ClearTmpDir (); + Environment.SetEnvironmentVariable ("MONO_ADDINS_REGISTRY", rootDir); + Environment.SetEnvironmentVariable ("XDG_CONFIG_HOME", rootDir); + Runtime.Initialize (true); + Gtk.Application.Init (); + ProjectDomService.TrackFileChanges = true; + DesktopService.Initialize (); + MonoDevelop.Projects.Services.ProjectService.DefaultTargetFramework = Runtime.SystemAssemblyService.GetTargetFramework ("2.0"); + } + [TestFixtureTearDown] public virtual void TearDown () |