Skip to content

Commit 22ed3f4

Browse files
Remove mocks of setting services for unit tests
Rather than mocking a bunch of VS services that are involved in reading services to be no-ops, we can just exclude the option persister to start with. This just ensures they're better isolated no matter what.
1 parent e6f9a9c commit 22ed3f4

File tree

4 files changed

+2
-303
lines changed

4 files changed

+2
-303
lines changed

src/EditorFeatures/TestUtilities/StubLocalRegistry.cs

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/EditorFeatures/TestUtilities/StubSettingsManagerHost.cs

Lines changed: 0 additions & 183 deletions
This file was deleted.

src/VisualStudio/TestUtilities2/MockServiceProvider.vb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
2828

2929
Private ReadOnly _exportProvider As Composition.ExportProvider
3030
Private ReadOnly _fileChangeEx As New MockVsFileChangeEx
31-
Private ReadOnly _localRegistry As New StubLocalRegistry
32-
Private _settingsManager As ISettingsManager
3331

3432
Public MockMonitorSelection As IVsMonitorSelection
3533

@@ -61,17 +59,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
6159
Case GetType(SVsFileChangeEx)
6260
Return _fileChangeEx
6361

64-
Case GetType(SLocalRegistry)
65-
Return _localRegistry
66-
67-
Case GetType(SVsSettingsPersistenceManager)
68-
If _settingsManager Is Nothing Then
69-
LoggerFactory.Reset()
70-
_settingsManager = SettingsManagerFactory.CreateInstance(New StubSettingsManagerHost())
71-
End If
72-
73-
Return _settingsManager
74-
7562
Case Else
7663
Throw New Exception($"{NameOf(MockServiceProvider)} does not implement {serviceType.FullName}.")
7764
End Select

src/VisualStudio/TestUtilities2/VisualStudioTestCompositions.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Imports Microsoft.CodeAnalysis.Editor.Host
66
Imports Microsoft.CodeAnalysis.Editor.UnitTests
7-
Imports Microsoft.CodeAnalysis.Notification
87
Imports Microsoft.CodeAnalysis.Test.Utilities
98
Imports Microsoft.VisualStudio.LanguageServices.CSharp
109
Imports Microsoft.VisualStudio.LanguageServices.Remote
@@ -26,6 +25,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
2625
GetType(VisualStudioRemoteHostClientProvider.Factory), ' Do not use ServiceHub in VS unit tests, run services locally.
2726
GetType(IStreamingFindUsagesPresenter), ' TODO: should we be using the actual implementation (https://github.com/dotnet/roslyn/issues/46380)?
2827
GetType(HACK_ThemeColorFixer),
29-
GetType(Implementation.Notification.VSNotificationServiceFactory))
28+
GetType(Implementation.Notification.VSNotificationServiceFactory),
29+
GetType(Options.VisualStudioOptionPersisterProvider)) ' Unit tests shouldn't depend on environmental user settings that might be set (even if we could read them)
3030
End Class
3131
End Namespace

0 commit comments

Comments
 (0)