public UnitTestMarker (ExtensibleTextEditor textEditor, UnitTestMarkerHost host, UnitTestLocation unitTest)
		{
			if (textEditor == null)
				throw new ArgumentNullException ("textEditor");
			if (host == null)
				throw new ArgumentNullException ("host");
			this.textEditor = textEditor;
			this.host = host;
			this.unitTest = unitTest;
		}
		IUnitTestMarker ITextMarkerFactory.CreateUnitTestMarker (MonoDevelop.Ide.Editor.TextEditor editor, UnitTestMarkerHost host, UnitTestLocation unitTestLocation)
		{
			return new UnitTestMarker (TextEditor, host, unitTestLocation);
		}
示例#3
0
 public static IUnitTestMarker CreateUnitTestMarker(TextEditor editor, UnitTestMarkerHost host, UnitTestLocation unitTestLocation)
 {
     return(editor.TextMarkerFactory.CreateUnitTestMarker(editor, host, unitTestLocation));
 }
			void TagClass (ClassDeclarationSyntax c)
			{
				if (unitTestClasses.Contains (c))
					return;
				unitTestClasses.Add (c);

				var type = semanticModel.GetDeclaredSymbol (c);
				var test = new UnitTestLocation (c.Identifier.SpanStart);
				test.IsFixture = true;
				test.UnitTestIdentifier = GetFullName (c);
				foundTests.Add (test);

				if (test != null) {
					foreach (var attr in type.GetAttributes ()) {
							test.IsIgnored |= attr.AttributeClass.GetFullName () == "NUnit.Framework.IgnoreAttribute";
					}
				}
			}
		public abstract void PopupContextMenu (UnitTestLocation unitTest, int x, int y);
			public override void VisitMethodDeclaration (MethodDeclarationSyntax node)
			{
				var method = semanticModel.GetDeclaredSymbol (node);
				if (method == null)
					return;
				var parentClass = node.Parent as ClassDeclarationSyntax;
				if (parentClass == null)
					return;
				UnitTestLocation test = null;
				foreach (var attr in method.GetAttributes ()) {
					if (attr.AttributeClass.GetFullName () == "NUnit.Framework.TestAttribute") {
						if (test == null) {
							TagClass (parentClass);
							test = new UnitTestLocation (node.Identifier.SpanStart);
							test.UnitTestIdentifier = GetFullName (parentClass) + "." + method.Name;
							foundTests.Add (test);
						}
					}
				}
				if (test != null) {
					foreach (var attr in method.GetAttributes ()) {
						if (attr.AttributeClass.GetFullName () == "NUnit.Framework.TestCaseAttribute") {
							test.TestCases.Add ("(" + BuildArguments (attr) + ")");
						} else
							test.IsIgnored |= attr.AttributeClass.GetFullName () == "NUnit.Framework.IgnoreAttribute";
					}
				}
			}
示例#7
0
 public abstract void PopupContextMenu(UnitTestLocation unitTest, int x, int y);
			public override void PopupContextMenu (UnitTestLocation unitTest, int x, int y)
			{
				var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode ();
				var project = ext?.DocumentContext?.Project;
				if (project == null)
					return;
				var menu = new ContextMenu ();
				if (unitTest.IsFixture) {
					var menuItem = new ContextMenuItem ("_Run All");
					menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, false).Run;
					menu.Add (menuItem);
					if (debugModeSet != null) {
						menuItem = new ContextMenuItem ("_Debug All");
						menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, true).Run;
						menu.Add (menuItem);
					}
					menuItem = new ContextMenuItem ("_Select in Test Pad");
					menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, true).Select;
					menu.Add (menuItem);
				} else {
					if (unitTest.TestCases.Count == 0) {
						var menuItem = new ContextMenuItem ("_Run");
						menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, false).Run;
						menu.Add (menuItem);
						if (debugModeSet != null) {
							menuItem = new ContextMenuItem ("_Debug");
							menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, true).Run;
							menu.Add (menuItem);
						}
						menuItem = new ContextMenuItem ("_Select in Test Pad");
						menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, true).Select;
						menu.Add (menuItem);
					} else {
						var menuItem = new ContextMenuItem ("_Run All");
						menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, false).Run;
						menu.Add (menuItem);
						if (debugModeSet != null) {
							menuItem = new ContextMenuItem ("_Debug All");
							menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier, project, true).Run;
							menu.Add (menuItem);
						}
						menu.Add (new SeparatorContextMenuItem ());
						foreach (var id in unitTest.TestCases) {
							var submenu = new ContextMenu ();
							menuItem = new ContextMenuItem ("_Run");
							menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier + id, project, false).Run;
							submenu.Add (menuItem);
							if (debugModeSet != null) {
								menuItem = new ContextMenuItem ("_Debug");
								menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier + id, project, true).Run;
								submenu.Add (menuItem);
							}

							var label = "Test" + id;
							string tooltip = null;
							var test = UnitTestService.SearchTestById (unitTest.UnitTestIdentifier + id);
							if (test != null) {
								var result = test.GetLastResult ();
								if (result != null && result.IsFailure) {
									tooltip = result.Message;
									label += "!";
								}
							}

							menuItem = new ContextMenuItem ("_Select in Test Pad");
							menuItem.Clicked += new TestRunner (unitTest.UnitTestIdentifier + id, project, true).Select;
							submenu.Add (menuItem);

							var subMenuItem = new ContextMenuItem (label);
							// if (!string.IsNullOrEmpty (tooltip))
							//	subMenuItem.TooltipText = tooltip;
							subMenuItem.SubMenu  = submenu;
							menu.Add (subMenuItem);
						}
					}
				}
				menu.Show (ext.Editor, x, y);
			}
			public override void VisitMethodDeclaration (MethodDeclarationSyntax node)
			{
				var method = semanticModel.GetDeclaredSymbol (node);
				if (method == null)
					return;
				var parentClass = node.Parent as ClassDeclarationSyntax;
				if (parentClass == null)
					return;
				UnitTestLocation test = null;
				IUnitTestMarkers markers = null;
				foreach (var attr in method.GetAttributes ()) {
					var cname = attr.AttributeClass.GetFullName ();
					markers = unitTestMarkers.FirstOrDefault (m => m.TestMethodAttributeMarker == cname);
					if (markers != null) {
						if (test == null) {
							TagClass (parentClass, markers);
							test = new UnitTestLocation (node.Identifier.SpanStart);
							test.UnitTestIdentifier = GetFullName (parentClass) + "." + method.Name;
							foundTests.Add (test);
						}
					}
				}
				if (test != null) {
					foreach (var attr in method.GetAttributes ()) {
						if (attr.AttributeClass.GetFullName () == markers.TestCaseMethodAttributeMarker) {
							test.TestCases.Add ("(" + BuildArguments (attr) + ")");
						} else
							test.IsIgnored |= attr.AttributeClass.GetFullName () == markers.IgnoreTestMethodAttributeMarker;
					}
				}
			}
示例#10
0
		public static IUnitTestMarker CreateUnitTestMarker (TextEditor editor, UnitTestMarkerHost host, UnitTestLocation unitTestLocation)
		{
			return editor.TextMarkerFactory.CreateUnitTestMarker (editor, host, unitTestLocation);
		}