diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2015-02-27 23:32:58 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2015-03-18 17:32:48 +0300 |
commit | 63d783a94ae209eccf1d38d856afff58db30e8f7 (patch) | |
tree | 96564635c2f8f271f36f10ca3cd75ac34d5bdbea /main/src/addins/NUnit | |
parent | a8a7389179acc7653dde5138eca53d5dc196a3f5 (diff) |
[NUnit] Fix test pad refresh issue
Diffstat (limited to 'main/src/addins/NUnit')
-rw-r--r-- | main/src/addins/NUnit/Services/NUnitService.cs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/main/src/addins/NUnit/Services/NUnitService.cs b/main/src/addins/NUnit/Services/NUnitService.cs index fdbd6eaf1b..6304346a25 100644 --- a/main/src/addins/NUnit/Services/NUnitService.cs +++ b/main/src/addins/NUnit/Services/NUnitService.cs @@ -53,9 +53,14 @@ namespace MonoDevelop.NUnit IdeApp.Workspace.WorkspaceItemClosed += OnWorkspaceChanged; IdeApp.Workspace.ActiveConfigurationChanged += OnWorkspaceChanged; + IdeApp.Workspace.ItemAddedToSolution += OnItemsChangedInSolution;; + IdeApp.Workspace.ItemRemovedFromSolution += OnItemsChangedInSolution; + IdeApp.Workspace.ReferenceAddedToProject += OnReferenceChangedInProject;; + IdeApp.Workspace.ReferenceRemovedFromProject += OnReferenceChangedInProject; + Mono.Addins.AddinManager.AddExtensionNodeHandler ("/MonoDevelop/NUnit/TestProviders", OnExtensionChange); } - + public static NUnitService Instance { get { if (instance == null) { @@ -259,7 +264,34 @@ namespace MonoDevelop.NUnit { RebuildTests (); } - + + void OnReferenceChangedInProject (object sender, ProjectReferenceEventArgs e) + { + if (!IsSolutionGroupPresent (e.Project.ParentSolution, rootTests)) + RebuildTests (); + } + + void OnItemsChangedInSolution (object sender, SolutionItemChangeEventArgs e) + { + if (!IsSolutionGroupPresent (e.Solution, rootTests)) + RebuildTests (); + } + + bool IsSolutionGroupPresent (Solution sol, IEnumerable<UnitTest> tests) + { + foreach (var t in tests) { + var tg = t as SolutionFolderTestGroup; + if (tg != null && ((SolutionFolder)tg.OwnerObject).ParentSolution == sol) + return true; + var g = t as UnitTestGroup; + if (g != null && g.HasTests) { + if (IsSolutionGroupPresent (sol, g.Tests)) + return true; + } + } + return false; + } + void RebuildTests () { if (rootTests != null) { |