diff --git a/src/ConnectedMode.UnitTests/Binding/ServerConnectionConfigurationProviderTests.cs b/src/ConnectedMode.UnitTests/Binding/ServerConnectionConfigurationProviderTests.cs index 58e73badde..8558bdd5fb 100644 --- a/src/ConnectedMode.UnitTests/Binding/ServerConnectionConfigurationProviderTests.cs +++ b/src/ConnectedMode.UnitTests/Binding/ServerConnectionConfigurationProviderTests.cs @@ -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(); - _ = testSubject.GetServerConnectionConfiguration(); - - solutionBindingRepository.Verify(sbr => sbr.List(), Times.Once()); - solutionBindingRepository.VerifyNoOtherCalls(); - } - [TestMethod] public void GetServerConnectionConfiguration_ThrowsOnUIThread() { diff --git a/src/ConnectedMode/Binding/ServerConnectionConfigurationProvider.cs b/src/ConnectedMode/Binding/ServerConnectionConfigurationProvider.cs index dceea9af79..c67263e42a 100644 --- a/src/ConnectedMode/Binding/ServerConnectionConfigurationProvider.cs +++ b/src/ConnectedMode/Binding/ServerConnectionConfigurationProvider.cs @@ -39,8 +39,6 @@ internal class ServerConnectionConfigurationProvider : IServerConnectionConfigur private readonly IThreadHandling threadHandling; private readonly IConnectionIdHelper connectionIdHelper; - private List bindingList = null; - [ImportingConstructor] [ExcludeFromCodeCoverage] public ServerConnectionConfigurationProvider(ISolutionBindingRepository solutionBindingRepository) @@ -56,17 +54,10 @@ internal ServerConnectionConfigurationProvider(ISolutionBindingRepository soluti } public IEnumerable GetServerConnectionConfiguration() where T : ServerConnectionConfiguration - { - if (bindingList == null) { InitBindingList(); } - - return bindingList.OfType(); - } - - private void InitBindingList() { threadHandling.ThrowIfOnUIThread(); - bindingList = new List(); + var bindingList = new List(); var bindings = solutionBindingRepository.List().Distinct(new BoundSonarQubeProjectUriComparer()); @@ -83,6 +74,8 @@ private void InitBindingList() bindingList.Add(new SonarQubeConnectionConfigurationDto(connectionID, true, binding.ServerUri.ToString())); } } + + return bindingList.OfType(); } private sealed class BoundSonarQubeProjectUriComparer : IEqualityComparer