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

Change ProjectRootCalculator to use IActiveSolutionBoundTracker #5071

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ConnectedMode.UnitTests/ProjectRootCalculatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void MefCtor_CheckIsExported()
{
MefTestHelpers.CheckTypeCanBeImported<ProjectRootCalculator, IProjectRootCalculator>(
MefTestHelpers.CreateExport<ISonarQubeService>(),
MefTestHelpers.CreateExport<IConfigurationProvider>(),
MefTestHelpers.CreateExport<IActiveSolutionBoundTracker>(),
MefTestHelpers.CreateExport<IStatefulServerBranchProvider>());
}

Expand All @@ -49,7 +49,7 @@ public void MefCtor_CheckIsSingleton()
public async Task CalculateBasedOnLocalPathAsync_StandaloneMode_ReturnsNull()
{
var testSubject = CreateTestSubject(out _, out var configurationProviderMock, out _);
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the variable name maybe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, since this is pretty much is used like a configuration provider, I think it's not too confusing, and I'd rather just leave it like this and be done with the pr

configurationProviderMock.Setup(x => x.GetConfiguration()).Returns(BindingConfiguration.Standalone);
configurationProviderMock.SetupGet(x => x.CurrentConfiguration).Returns(BindingConfiguration.Standalone);

var result = await testSubject.CalculateBasedOnLocalPathAsync(@"c:\somepath", CancellationToken.None);

Expand All @@ -64,7 +64,7 @@ public async Task CalculateBasedOnLocalPathAsync_ConnectedMode_ReturnsCorrectRoo

var testSubject = CreateTestSubject(out var sonarQubeServiceMock, out var configurationProviderMock, out var branchProviderMock);
configurationProviderMock
.Setup(x => x.GetConfiguration())
.SetupGet(x => x.CurrentConfiguration)
.Returns(BindingConfiguration.CreateBoundConfiguration(
new BoundSonarQubeProject(){ProjectKey = projectKey},
SonarLintMode.Connected,
Expand All @@ -82,11 +82,11 @@ public async Task CalculateBasedOnLocalPathAsync_ConnectedMode_ReturnsCorrectRoo
}

private ProjectRootCalculator CreateTestSubject(out Mock<ISonarQubeService> sonarQubeServiceMock,
out Mock<IConfigurationProvider> configurationProviderMock,
out Mock<IActiveSolutionBoundTracker> activeSolutionBoundTracker,
out Mock<IStatefulServerBranchProvider> statefulServerBranchProviderMock)
{
return new ProjectRootCalculator((sonarQubeServiceMock = new Mock<ISonarQubeService>(MockBehavior.Strict)).Object,
(configurationProviderMock = new Mock<IConfigurationProvider>(MockBehavior.Strict)).Object,
(activeSolutionBoundTracker = new Mock<IActiveSolutionBoundTracker>(MockBehavior.Strict)).Object,
(statefulServerBranchProviderMock = new Mock<IStatefulServerBranchProvider>(MockBehavior.Strict)).Object);
}
}
8 changes: 4 additions & 4 deletions src/ConnectedMode/ProjectRootCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ internal interface IProjectRootCalculator
internal class ProjectRootCalculator : IProjectRootCalculator
{
private readonly ISonarQubeService sonarQubeService;
private readonly IConfigurationProvider configurationProvider;
private readonly IActiveSolutionBoundTracker activeSolutionBoundTracker;
private readonly IStatefulServerBranchProvider branchProvider;

[ImportingConstructor]
public ProjectRootCalculator(ISonarQubeService sonarQubeService, IConfigurationProvider configurationProvider, IStatefulServerBranchProvider branchProvider)
public ProjectRootCalculator(ISonarQubeService sonarQubeService, IActiveSolutionBoundTracker activeSolutionBoundTracker, IStatefulServerBranchProvider branchProvider)
{
this.sonarQubeService = sonarQubeService;
this.configurationProvider = configurationProvider;
this.activeSolutionBoundTracker = activeSolutionBoundTracker;
this.branchProvider = branchProvider;
}

public async Task<string> CalculateBasedOnLocalPathAsync(string localPath, CancellationToken token)
{
var bindingConfiguration = configurationProvider.GetConfiguration();
var bindingConfiguration = activeSolutionBoundTracker.CurrentConfiguration;

if (bindingConfiguration.Mode == SonarLintMode.Standalone)
{
Expand Down