Browse Source

Fix some issues in the unit testing AddIn.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
9ab4031e9f
  1. 2
      src/AddIns/Analysis/UnitTesting/Commands/RunTestCommands.cs
  2. 23
      src/AddIns/Analysis/UnitTesting/Commands/UnitTestCommands.cs
  3. 2
      src/AddIns/Analysis/UnitTesting/Interfaces/ITestTreeView.cs
  4. 2
      src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs
  5. 3
      src/AddIns/Analysis/UnitTesting/Service/TestService.cs
  6. 4
      src/AddIns/Analysis/UnitTesting/Service/TestableCondition.cs
  7. 4
      src/AddIns/Analysis/UnitTesting/TestTreeView.cs
  8. 13
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpMethodInsight.cs

2
src/AddIns/Analysis/UnitTesting/Commands/RunTestCommands.cs

@ -531,7 +531,7 @@ namespace ICSharpCode.UnitTesting @@ -531,7 +531,7 @@ namespace ICSharpCode.UnitTesting
get { return null; }
}
public ITypeDefinition SelectedClass {
public TestClass SelectedClass {
get { return null; }
}

23
src/AddIns/Analysis/UnitTesting/Commands/UnitTestCommands.cs

@ -57,33 +57,26 @@ namespace ICSharpCode.UnitTesting @@ -57,33 +57,26 @@ namespace ICSharpCode.UnitTesting
{
ITestTreeView treeView = Owner as ITestTreeView;
if (treeView != null) {
IMethod method = treeView.SelectedMethod.Resolve();
ITypeDefinition c = treeView.SelectedClass;
var method = treeView.SelectedMethod;
var c = treeView.SelectedClass;
if (method != null) {
GotoMember(method);
GotoMember(method.Resolve());
} else if (c != null) {
GotoClass(c);
GotoClass(c.Resolve());
}
}
}
void GotoMember(IMember member)
{
GotoFilePosition(member.Region);
if (member != null)
NavigationService.NavigateTo(member);
}
void GotoClass(ITypeDefinition c)
{
GotoFilePosition(c.Region);
}
void GotoFilePosition(DomRegion filePosition)
{
if (filePosition.IsEmpty) {
fileService.OpenFile(new FileName(filePosition.FileName));
} else {
fileService.JumpToFilePosition(new FileName(filePosition.FileName), filePosition.BeginLine, filePosition.BeginColumn);
}
if (c != null)
NavigationService.NavigateTo(c);
}
}

2
src/AddIns/Analysis/UnitTesting/Interfaces/ITestTreeView.cs

@ -18,7 +18,7 @@ namespace ICSharpCode.UnitTesting @@ -18,7 +18,7 @@ namespace ICSharpCode.UnitTesting
/// <summary>
/// Gets the selected class in the test tree view.
/// </summary>
ITypeDefinition SelectedClass {get;}
TestClass SelectedClass {get;}
/// <summary>
/// Gets the selected project for the selected node

2
src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestFramework.cs

@ -65,6 +65,8 @@ namespace ICSharpCode.UnitTesting @@ -65,6 +65,8 @@ namespace ICSharpCode.UnitTesting
{
if (type == null)
throw new ArgumentNullException("type");
if (type.IsAbstract)
return false;
var testAttribute = NUnitTestFramework.testAttribute.Resolve(compilation.TypeResolveContext);
var testCaseAttribute = NUnitTestFramework.testCaseAttribute.Resolve(compilation.TypeResolveContext);
return type.Methods.Any(m => m.Attributes.Any(a => a.AttributeType.Equals(testAttribute) || a.AttributeType.Equals(testCaseAttribute)));

3
src/AddIns/Analysis/UnitTesting/Service/TestService.cs

@ -64,6 +64,9 @@ namespace ICSharpCode.UnitTesting @@ -64,6 +64,9 @@ namespace ICSharpCode.UnitTesting
ProjectService.ProjectAdded += ProjectService_ProjectAdded;
ProjectService.ProjectRemoved += ProjectService_ProjectRemoved;
SD.ParserService.LoadSolutionProjectsThread.Finished += SD_ParserService_LoadSolutionProjectsThread_Finished;
// TODO: get rid of static service.
// We don't even know for sure that we're on the main thread when the cctor runs
SD_ParserService_LoadSolutionProjectsThread_Finished(null, null);
}
static void SD_ParserService_LoadSolutionProjectsThread_Finished(object sender, EventArgs e)

4
src/AddIns/Analysis/UnitTesting/Service/TestableCondition.cs

@ -46,8 +46,8 @@ namespace ICSharpCode.UnitTesting @@ -46,8 +46,8 @@ namespace ICSharpCode.UnitTesting
public static ITypeDefinition GetClass(object caller)
{
ITestTreeView testTreeView = caller as ITestTreeView;
if (testTreeView != null) {
return testTreeView.SelectedClass;
if (testTreeView != null && testTreeView.SelectedClass != null) {
return testTreeView.SelectedClass.Resolve();
}
// ClassNode classNode = caller as ClassNode;
// if (classNode != null)

4
src/AddIns/Analysis/UnitTesting/TestTreeView.cs

@ -71,7 +71,7 @@ namespace ICSharpCode.UnitTesting @@ -71,7 +71,7 @@ namespace ICSharpCode.UnitTesting
/// <summary>
/// Gets the class of the currently selected tree node.
/// </summary>
public ITypeDefinition SelectedClass {
public TestClass SelectedClass {
get {
ClassUnitTestNode classNode = SelectedItem as ClassUnitTestNode;
if (classNode == null) {
@ -79,7 +79,7 @@ namespace ICSharpCode.UnitTesting @@ -79,7 +79,7 @@ namespace ICSharpCode.UnitTesting
}
if (classNode != null) {
return classNode.TestClass.Resolve();
return classNode.TestClass;
}
return null;
}

13
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpMethodInsight.cs

@ -8,6 +8,7 @@ using System.Linq; @@ -8,6 +8,7 @@ using System.Linq;
using ICSharpCode.NRefactory.Completion;
using ICSharpCode.NRefactory.CSharp.Completion;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
@ -20,6 +21,7 @@ namespace CSharpBinding.Completion @@ -20,6 +21,7 @@ namespace CSharpBinding.Completion
readonly CSharpCompletionBinding binding;
readonly ITextEditor editor;
IInsightWindow window;
CSharpInsightItem initiallySelectedItem;
public CSharpMethodInsight(CSharpCompletionBinding binding, ITextEditor editor, int startOffset, IEnumerable<CSharpInsightItem> items)
{
@ -38,6 +40,8 @@ namespace CSharpBinding.Completion @@ -38,6 +40,8 @@ namespace CSharpBinding.Completion
window.StartOffset = startOffset;
// closing the window at the end of the parameter list is handled by the CaretPositionChanged event
window.EndOffset = editor.Document.TextLength;
if (initiallySelectedItem != null)
window.SelectedItem = initiallySelectedItem;
window.CaretPositionChanged += window_CaretPositionChanged;
}
@ -65,6 +69,15 @@ namespace CSharpBinding.Completion @@ -65,6 +69,15 @@ namespace CSharpBinding.Completion
if (parameterIndex < 0 && window != null) {
window.Close();
} else {
if (window == null || parameterIndex > ((CSharpInsightItem)window.SelectedItem).Method.Parameters.Count) {
var newItem = items.FirstOrDefault(i => parameterIndex <= i.Method.Parameters.Count);
if (newItem != null) {
if (window != null)
window.SelectedItem = newItem;
else
initiallySelectedItem = newItem;
}
}
if (parameterIndex > 0)
parameterIndex--; // NR returns 1-based parameter index
foreach (var item in items)

Loading…
Cancel
Save