Пример #1
0
 public override bool HasResult(string unitTestIdentifier, string caseId = null)
 {
     return(UnitTestService.SearchTestById(unitTestIdentifier + caseId) != null);
 }
Пример #2
0
            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(GettextCatalog.GetString("_Run All"));
                    menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run;
                    menu.Add(menuItem);
                    if (debugModeSet != null)
                    {
                        menuItem          = new ContextMenuItem(GettextCatalog.GetString("_Debug All"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Run;
                        menu.Add(menuItem);
                    }
                    menuItem          = new ContextMenuItem(GettextCatalog.GetString("_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(GettextCatalog.GetString("_Run"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run;
                        menu.Add(menuItem);
                        if (debugModeSet != null)
                        {
                            menuItem          = new ContextMenuItem(GettextCatalog.GetString("_Debug"));
                            menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Run;
                            menu.Add(menuItem);
                        }
                        menuItem          = new ContextMenuItem(GettextCatalog.GetString("_Select in Test Pad"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Select;
                        menu.Add(menuItem);
                    }
                    else
                    {
                        var menuItem = new ContextMenuItem(GettextCatalog.GetString("_Run All"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run;
                        menu.Add(menuItem);
                        if (debugModeSet != null)
                        {
                            menuItem          = new ContextMenuItem(GettextCatalog.GetString("_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(GettextCatalog.GetString("_Run"));
                            menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier + id, project, false).Run;
                            submenu.Add(menuItem);
                            if (debugModeSet != null)
                            {
                                menuItem          = new ContextMenuItem(GettextCatalog.GetString("_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(GettextCatalog.GetString("_Select in Test Pad"));
                            menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier + id, project, true).Select;
                            submenu.Add(menuItem);

                            const int maxLabelLength = 80;
                            var       trimmedLabel   = label.Trim();
                            if (trimmedLabel.Length > maxLabelLength)
                            {
                                const char gap           = '\u2026';
                                int        remainsLength = (maxLabelLength - 1) / 2;
                                string     start         = trimmedLabel.Substring(0, remainsLength);
                                string     end           = trimmedLabel.Substring(trimmedLabel.Length - remainsLength, remainsLength);
                                label = $"{start.TrimEnd()}{gap}{end.TrimStart ()}";
                            }

                            var subMenuItem = new ContextMenuItem(label);
                            // if (!string.IsNullOrEmpty (tooltip))
                            //	subMenuItem.TooltipText = tooltip;
                            subMenuItem.SubMenu = submenu;
                            menu.Add(subMenuItem);
                        }
                    }
                }
                // FIXME: enforce public API by casting Control to Gtk.Widget, because of IVT
                menu.Show((Gtk.Widget)ext.Editor, x, 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(GettextCatalog.GetString("_Run All"));
                    menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run;
                    menu.Add(menuItem);
                    if (debugModeSet != null)
                    {
                        menuItem          = new ContextMenuItem(GettextCatalog.GetString("_Debug All"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Run;
                        menu.Add(menuItem);
                    }
                    menuItem          = new ContextMenuItem(GettextCatalog.GetString("_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(GettextCatalog.GetString("_Run"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run;
                        menu.Add(menuItem);
                        if (debugModeSet != null)
                        {
                            menuItem          = new ContextMenuItem(GettextCatalog.GetString("_Debug"));
                            menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Run;
                            menu.Add(menuItem);
                        }
                        menuItem          = new ContextMenuItem(GettextCatalog.GetString("_Select in Test Pad"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Select;
                        menu.Add(menuItem);
                    }
                    else
                    {
                        var menuItem = new ContextMenuItem(GettextCatalog.GetString("_Run All"));
                        menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run;
                        menu.Add(menuItem);
                        if (debugModeSet != null)
                        {
                            menuItem          = new ContextMenuItem(GettextCatalog.GetString("_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(GettextCatalog.GetString("_Run"));
                            menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier + id, project, false).Run;
                            submenu.Add(menuItem);
                            if (debugModeSet != null)
                            {
                                menuItem          = new ContextMenuItem(GettextCatalog.GetString("_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(GettextCatalog.GetString("_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);
            }