Skip to content

Commit

Permalink
removed caching
Browse files Browse the repository at this point in the history
  • Loading branch information
ugras-ergun-sonarsource committed Feb 20, 2024
1 parent ce6fc35 commit 2760643
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ public void GetServerConnectionConfiguration_HaveMultipleBindingWithSameUri_Aggr
scBindings.Should().HaveCount(1);
}

[TestMethod]
public void GetServerConnectionConfiguration_CallsRepoOnce()
{
var solutionBindingRepository = CreateRepository();

var testSubject = CreateTestSubject(solutionBindingRepository.Object);

_ = testSubject.GetServerConnectionConfiguration<SonarQubeConnectionConfigurationDto>();
_ = testSubject.GetServerConnectionConfiguration<SonarQubeConnectionConfigurationDto>();

solutionBindingRepository.Verify(sbr => sbr.List(), Times.Once());
solutionBindingRepository.VerifyNoOtherCalls();
}

[TestMethod]
public void GetServerConnectionConfiguration_ThrowsOnUIThread()
{
Expand Down
13 changes: 3 additions & 10 deletions src/ConnectedMode/Binding/ServerConnectionConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ internal class ServerConnectionConfigurationProvider : IServerConnectionConfigur
private readonly IThreadHandling threadHandling;
private readonly IConnectionIdHelper connectionIdHelper;

private List<ServerConnectionConfiguration> bindingList = null;

[ImportingConstructor]
[ExcludeFromCodeCoverage]
public ServerConnectionConfigurationProvider(ISolutionBindingRepository solutionBindingRepository)
Expand All @@ -56,17 +54,10 @@ internal ServerConnectionConfigurationProvider(ISolutionBindingRepository soluti
}

public IEnumerable<T> GetServerConnectionConfiguration<T>() where T : ServerConnectionConfiguration
{
if (bindingList == null) { InitBindingList(); }

return bindingList.OfType<T>();
}

private void InitBindingList()
{
threadHandling.ThrowIfOnUIThread();

bindingList = new List<ServerConnectionConfiguration>();
var bindingList = new List<ServerConnectionConfiguration>();

var bindings = solutionBindingRepository.List().Distinct(new BoundSonarQubeProjectUriComparer());

Expand All @@ -83,6 +74,8 @@ private void InitBindingList()
bindingList.Add(new SonarQubeConnectionConfigurationDto(connectionID, true, binding.ServerUri.ToString()));
}
}

return bindingList.OfType<T>();
}

private sealed class BoundSonarQubeProjectUriComparer : IEqualityComparer<BoundSonarQubeProject>
Expand Down

0 comments on commit 2760643

Please sign in to comment.