diff options
author | David Karlaš <david.karlas@microsoft.com> | 2018-01-22 16:02:59 +0300 |
---|---|---|
committer | David Karlaš <david.karlas@microsoft.com> | 2018-01-23 10:51:13 +0300 |
commit | edbb3ba2ce8aa3cefa79f43b1e88837b8de79a6b (patch) | |
tree | 972e98a7e25817cbff0ea927832e99f29507af85 /main/src/addins/MonoDevelop.UnitTesting | |
parent | 40ad6efcaa58306fb944a4edd7628baad9201b9a (diff) |
Fix 525841 - Unit tests window displays blank after the .Net Core xunits console project is build after restoring the Nuget packages
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r-- | main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestAdapter.cs | 12 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs | 8 |
2 files changed, 17 insertions, 3 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestAdapter.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestAdapter.cs index 7b54f21545..da3c611b6b 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestAdapter.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestAdapter.cs @@ -82,9 +82,16 @@ namespace MonoDevelop.UnitTesting.VsTest return cachePackages.Item2; var result = string.Empty; + bool cache = true; foreach (var folder in nugetsFolders) { - if (string.IsNullOrEmpty (folder) || !Directory.Exists (folder)) + if (string.IsNullOrEmpty (folder)) continue; + if (!Directory.Exists (folder)) { + //NuGet gives us valid location of where package will be restored + //so we may not cache invalid result until package has been actually restored + cache = false; + continue; + } foreach (var path in Directory.GetFiles (folder, "*.TestAdapter.dll", SearchOption.AllDirectories)) result += path + ";"; foreach (var path in Directory.GetFiles (folder, "*.testadapter.dll", SearchOption.AllDirectories)) @@ -94,7 +101,8 @@ namespace MonoDevelop.UnitTesting.VsTest if (result.Length > 0) result = result.Remove (result.Length - 1); projectTestAdapterListCache.Remove (project); - projectTestAdapterListCache.Add (project, new Tuple<HashSet<string>, string> (new HashSet<string> (nugetsFolders), result)); + if (cache) + projectTestAdapterListCache.Add (project, new Tuple<HashSet<string>, string> (new HashSet<string> (nugetsFolders), result)); return result; } } diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs index c0717cbc20..a122b5e380 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs @@ -64,6 +64,7 @@ namespace MonoDevelop.UnitTesting PackageManagementServices.ProjectOperations.PackageReferenceAdded += ProjectOperations_PackageReferencesModified; PackageManagementServices.ProjectOperations.PackageReferenceRemoved += ProjectOperations_PackageReferencesModified; + PackageManagementServices.ProjectOperations.PackagesRestored += ProjectOperations_PackageReferencesModified; Mono.Addins.AddinManager.AddExtensionNodeHandler ("/MonoDevelop/UnitTesting/TestProviders", OnExtensionChange); @@ -323,7 +324,7 @@ namespace MonoDevelop.UnitTesting static CancellationTokenSource throttling = new CancellationTokenSource (); - static void ProjectOperations_PackageReferencesModified (object sender, PackageManagementPackageReferenceEventArgs e) + static void ProjectOperations_PackageReferencesModified(object sender, EventArgs e) { throttling.Cancel (); throttling = new CancellationTokenSource (); @@ -334,6 +335,11 @@ namespace MonoDevelop.UnitTesting }, throttling.Token, TaskContinuationOptions.None, Runtime.MainTaskScheduler); } + static void ProjectOperations_PackageReferencesModified (object sender, PackageManagementPackageReferenceEventArgs e) + { + ProjectOperations_PackageReferencesModified (sender, e); + } + static bool IsSolutionGroupPresent (Solution sol, IEnumerable<UnitTest> tests) { foreach (var t in tests) { |