Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to check if SonarQubeNavigationItem is free-threaded #4882

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

duncanp-sonar
Copy link
Contributor

Part of #4856

@sonarcloud
Copy link

sonarcloud bot commented Sep 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@duncanp-sonar duncanp-sonar marked this pull request as ready for review September 13, 2023 07:22
@@ -30,29 +32,49 @@ namespace SonarLint.VisualStudio.Integration.UnitTests.TeamExplorer
[TestClass]
public class SonarQubeNavigationItemTests
{
[TestMethod]
[Ignore] // Object is created successfully, but an exception when
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a separate ticket for this and fix it separately.

// There's no public documentation on how these whether it's ok to create WPF artefacts like brushes
// and icons in the constructor. However, this is what the VS Team Explorer implementations of this
// class are doing, so we assume it's ok.
// See [VS installation directory]\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Microsoft.TeamFoundation.TeamExplorer.Navigation.dll
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't obvious whether our code was ok or not, so I found and decompiled the VS implementations to check what they did.

[TestMethod]
public void SonarQubeNavigationItem_Execute()
{
// Arrange
var controller = new ConfigurableTeamExplorerController();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miscellaneous: minor cleanup. It was trivial to replace the helper class with a mock, and add a CreateTestSubject method.

@@ -28,6 +28,7 @@
namespace SonarLint.VisualStudio.Integration.TeamExplorer
{
[TeamExplorerNavigationItem(SonarQubeNavigationItem.ItemId, SonarQubeNavigationItem.Priority, TargetPageId = SonarQubePage.PageId)]
[PartCreationPolicy(CreationPolicy.NonShared)] // The VS navigations in MS.TeamFoundation.TeamExplorer.Navigation are non-shared
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VS components are marked as non-shared.

Copy link
Contributor

@bigfluffycookie bigfluffycookie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@duncanp-sonar duncanp-sonar merged commit cedb472 into branch-hardening-Aug23b Sep 13, 2023
4 checks passed
@duncanp-sonar duncanp-sonar deleted the dp/sqNavigItem branch September 13, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants