diff options
author | Dmytro Ovcharov <dmytro.ovcharov@globallogic.com> | 2017-10-26 16:54:01 +0300 |
---|---|---|
committer | Dmytro Ovcharov <dmytro.ovcharov@globallogic.com> | 2017-10-26 16:54:01 +0300 |
commit | e0a3bad805ee14200cf78f0617829b323a61d56d (patch) | |
tree | 2dab5960a44692807a2cb20e0475069e667af873 /main/src/addins/MonoDevelop.UnitTesting | |
parent | 6f17f0f1744a374bc3c5dd337c041cae1628b0e0 (diff) |
Removed redundant nesting in unit test tree.
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r-- | main/src/addins/MonoDevelop.UnitTesting/Gui/TestNodeBuilder.cs | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Gui/TestNodeBuilder.cs b/main/src/addins/MonoDevelop.UnitTesting/Gui/TestNodeBuilder.cs index 027f8b4265..1c5ea3a0cb 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Gui/TestNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Gui/TestNodeBuilder.cs @@ -29,6 +29,7 @@ using System; using System.Globalization; using System.Text; +using System.Linq; using MonoDevelop.Core; using MonoDevelop.Components.Commands; @@ -69,8 +70,15 @@ namespace MonoDevelop.UnitTesting UnitTest test = dataObject as UnitTest; nodeInfo.Icon = test.StatusIcon; + var singleTestSuffix = String.Empty; + if (test is UnitTestGroup unitTestGroup) + singleTestSuffix = GetSuxffix (unitTestGroup); + var title = RemoveGenericArgument (test.Title); - title = test.Title; + title = String.IsNullOrEmpty (singleTestSuffix) ? + test.Title : + $"{test.Title}{singleTestSuffix}"; + if (test.Status == TestStatus.Running) { nodeInfo.Label = Ambience.EscapeText (title); return; @@ -94,15 +102,49 @@ namespace MonoDevelop.UnitTesting } } + static string GetSuxffix (UnitTestGroup unitTestGroup) + { + var result = String.Empty; + if (!(unitTestGroup is SolutionFolderTestGroup)) + if (ContainsSingleUnitTestGroup (unitTestGroup)) { + var testCollection = unitTestGroup.Tests; + var singleChildTestGroup = testCollection.FirstOrDefault () as UnitTestGroup; + result = $".{singleChildTestGroup.Title}{GetSuxffix (singleChildTestGroup)}"; + } + return result; + } + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) { UnitTestGroup test = dataObject as UnitTestGroup; if (test == null) return; + if (ContainsSingleUnitTestGroup (test)) { + BuildChildNodes (test, builder); + return; + } builder.AddChildren (test.Tests); } + void BuildChildNodes (UnitTestGroup test, ITreeBuilder builder) + { + if (test == null || test.Tests == null) + return; + + bool isSolution = test is SolutionFolderTestGroup; + if (!isSolution && ContainsSingleUnitTestGroup(test)) { + var unitTestGroup = test.Tests.First () as UnitTestGroup; + BuildChildNodes (unitTestGroup, builder); + return; + } + builder.AddChildren (test.Tests); + } + + static bool ContainsSingleUnitTestGroup(UnitTestGroup test) => + test.Tests.Count () == 1 && + test.Tests.OfType<UnitTestGroup> ().Count () == 1; + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) { UnitTestGroup test = dataObject as UnitTestGroup; |