diff options
author | Mike Krüger <mkrueger@novell.com> | 2009-08-31 12:26:27 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2009-08-31 12:26:27 +0400 |
commit | d451e3359453e317d81cff2f752e889dfd1a758d (patch) | |
tree | acfa5a9133f2266c02f055047a8b9f05dae5e6d6 /main/tests | |
parent | 48f1f848363a8d43159574c525672cec219526cd (diff) |
* MonoDevelop.Refactoring/ExtractMethodTests.cs: Added some extract
method unit tests.
svn path=/trunk/monodevelop/; revision=140947
Diffstat (limited to 'main/tests')
-rw-r--r-- | main/tests/UnitTests/ChangeLog | 5 | ||||
-rw-r--r-- | main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs | 121 |
2 files changed, 111 insertions, 15 deletions
diff --git a/main/tests/UnitTests/ChangeLog b/main/tests/UnitTests/ChangeLog index 94517d5867..83d9386206 100644 --- a/main/tests/UnitTests/ChangeLog +++ b/main/tests/UnitTests/ChangeLog @@ -1,3 +1,8 @@ +2009-08-31 Mike Krüger <mkrueger@novell.com> + + * MonoDevelop.Refactoring/ExtractMethodTests.cs: Added some + extract method unit tests. + 2009-08-27 Mike Krüger <mkrueger@novell.com> * MonoDevelop.Projects/DomTests.cs: Fixed bug in unit test. diff --git a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs index 4ffe3e7da5..65fa5bc28d 100644 --- a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs +++ b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs @@ -144,30 +144,94 @@ namespace MonoDevelop.Refactoring.Tests return result.ToString (); } + void TestExtractMethod (string inputString, string outputString) + { + ExtractMethodRefactoring refactoring = new ExtractMethodRefactoring (); + RefactoringOptions options = CreateRefactoringOptions (inputString); + ExtractMethodRefactoring.ExtractMethodParameters parameters = refactoring.CreateParameters (options); + Assert.IsNotNull (parameters); + parameters.Name = "NewMethod"; + List<Change> changes = refactoring.PerformChanges (options, parameters); + + string output = GetOutput (options, changes); + Assert.IsTrue (CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output); + } [Test()] - public void ExtractMethodTest () + public void ExtractMethodResultStatementTest () { - ExtractMethodRefactoring refactoring = new ExtractMethodRefactoring (); - RefactoringOptions options = CreateRefactoringOptions ( -@"class TestClass + TestExtractMethod (@"class TestClass { + int member = 5; void TestMethod () { int i = 5; - <- i = i + 1; -> + <- i = member + 1; -> Console.WriteLine (i); } } +", @"class TestClass +{ + int member = 5; + void TestMethod () + { + int i = 5; + i = NewMethod (); + Console.WriteLine (i); + } + + int NewMethod () + { + int i; + i = member + 1; + return i; + } +} "); - ExtractMethodRefactoring.ExtractMethodParameters parameters = refactoring.CreateParameters (options); - Assert.IsNotNull (parameters); - parameters.Name = "NewMethod"; - List<Change> changes = refactoring.PerformChanges (options, parameters); - - string output = GetOutput (options, changes); - Assert.IsTrue (CompareSource (output, -@"class TestClass + } + + [Test()] + public void ExtractMethodResultExpressionTest () + { + TestExtractMethod (@"class TestClass +{ + int member =5; + void TestMethod () + { + int i = <- member + 1 ->; + Console.WriteLine (i); + } +} +", @"class TestClass +{ + int member =5; + void TestMethod () + { + int i = NewMethod (); + Console.WriteLine (i); + } + + int NewMethod () + { + return member + 1; + } +} +"); + } + + [Test()] + public void ExtractMethodStaticResultStatementTest () + { + TestExtractMethod (@"class TestClass +{ + void TestMethod () + { + int i = 5; + <- i = i + 1; -> + Console.WriteLine (i); + } +} +", @"class TestClass { void TestMethod () { @@ -182,8 +246,35 @@ namespace MonoDevelop.Refactoring.Tests return i; } } -")); -// Assert.IsTrue () +"); } + + [Test()] + public void ExtractMethodStaticResultExpressionTest () + { + TestExtractMethod (@"class TestClass +{ + void TestMethod () + { + int i = <- 5 + 1 ->; + Console.WriteLine (i); + } +} +", @"class TestClass +{ + void TestMethod () + { + int i = NewMethod (); + Console.WriteLine (i); + } + + static int NewMethod () + { + return 5 + 1; + } +} +"); + } + } } |