diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2013-07-10 17:55:54 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2013-07-10 17:56:09 +0400 |
commit | 3c51cf90fe27e4e69978f544a9b89fb12637dd83 (patch) | |
tree | 798c73c7c45a89b4e86aef57ca6ec0fb01c99587 /main/tests/UnitTests/MonoDevelop.CSharpBinding | |
parent | 7dc1034fe901466e3960b597ad591c7fc299867a (diff) |
[CSharpBinding] Implemented & tested auto bracket insertion.
Diffstat (limited to 'main/tests/UnitTests/MonoDevelop.CSharpBinding')
-rw-r--r-- | main/tests/UnitTests/MonoDevelop.CSharpBinding/AutomaticBracketInsertionTests.cs | 83 |
1 files changed, 80 insertions, 3 deletions
diff --git a/main/tests/UnitTests/MonoDevelop.CSharpBinding/AutomaticBracketInsertionTests.cs b/main/tests/UnitTests/MonoDevelop.CSharpBinding/AutomaticBracketInsertionTests.cs index efedc0c809..80653788fd 100644 --- a/main/tests/UnitTests/MonoDevelop.CSharpBinding/AutomaticBracketInsertionTests.cs +++ b/main/tests/UnitTests/MonoDevelop.CSharpBinding/AutomaticBracketInsertionTests.cs @@ -170,7 +170,7 @@ namespace MonoDevelop.CSharpBinding return compExt; } - string Test(string input, string type, string member) + string Test(string input, string type, string member, Gdk.Key key = Gdk.Key.Return, bool isDelegateExpected = false) { TestViewContent content; var ext = Setup (input, out content); @@ -183,12 +183,14 @@ namespace MonoDevelop.CSharpBinding var t = ext.Document.Compilation.FindType (new FullTypeName (type)); var method = t.GetMembers (m => m.Name == member).First (); var data = new MemberCompletionData (ext, method, OutputFlags.ClassBrowserEntries); - + data.IsDelegateExpected = isDelegateExpected; KeyActions ka = KeyActions.Process; - data.InsertCompletionText (listWindow, ref ka, Gdk.Key.Return, '\n', Gdk.ModifierType.None); + data.InsertCompletionText (listWindow, ref ka, key, (char)key, Gdk.ModifierType.None, true, false); return widget.CompletedWord; } + + [Test] public void TestSimpleCase () { @@ -199,9 +201,84 @@ namespace MonoDevelop.CSharpBinding $ } }", "MyClass", "FooBar"); + Assert.AreEqual ("FooBar ();|", completion); + } + + [Test] + public void TestOverloads () + { + string completion = Test (@"class MyClass +{ + void FooBar (int foo) + { + } + void FooBar () + { + $ + } +}", "MyClass", "FooBar"); Assert.AreEqual ("FooBar (|);", completion); } + [Test] + public void TestExpressionCase () + { + string completion = Test (@"class MyClass +{ + int FooBar () + { + int i; + i = $ + } +}", "MyClass", "FooBar"); + Assert.AreEqual ("FooBar ()|", completion); + } + + [Test] + public void TestExpressionCaseWithOverloads () + { + string completion = Test (@"class MyClass +{ + int FooBar (int foo) + { + } + + int FooBar () + { + int i; + i = $ + } +}", "MyClass", "FooBar"); + Assert.AreEqual ("FooBar (|)", completion); + } + + [Test] + public void TestDelegateCase () + { + string completion = Test (@"using System; +class MyClass +{ + int FooBar () + { + Func<int> i; + i = $ + } +}", "MyClass", "FooBar", Gdk.Key.Return, true); + Assert.AreEqual ("FooBar", completion); + } + + [Test] + public void TestDotCompletion () + { + string completion = Test (@"class MyClass +{ + void FooBar () + { + $ + } +}", "MyClass", "FooBar", (Gdk.Key)'.'); + Assert.AreEqual ("FooBar ().|", completion); + } } } |