/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/EditorFeatures/Test2/Workspaces/WpfTextBufferVisibilityTrackerTests.vb
44 строки
2 KB
Cyrus Najmabadi
Organize VB imports
27 июн 2025, 21:53
27 июн 2025, 21:53
e9c47fd
Код
Авторство
О чём код?
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Imports Microsoft.CodeAnalysis.Workspaces Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces <UseExportProvider> Public Class WpfTextBufferVisibilityTrackerTests <WpfFact> Public Sub TestMutationInCallback() Using workspace = EditorTestWorkspace.CreateCSharp("", composition:=EditorTestCompositions.EditorFeatures) Dim visibilityTracker = DirectCast(workspace.ExportProvider.GetExportedValue(Of ITextBufferVisibilityTracker), WpfTextBufferVisibilityTracker) Dim buffer = workspace.Documents.Single().GetTextBuffer() Dim action1Called = False Dim action2Called = False Dim action1 As Action = Nothing action1 = Sub() action1Called = True visibilityTracker.UnregisterForVisibilityChanges(buffer, action1) End Sub Dim action2 = Sub() action2Called = True End Sub visibilityTracker.RegisterForVisibilityChanges(buffer, action1) visibilityTracker.RegisterForVisibilityChanges(buffer, action2) ' Getting the text view will cause it to become visible which will iterate and invoke the actions. The first ' action callback will then unregister itself. This should must not break things, and we should still call action2. Dim view = workspace.Documents.Single().GetTextView() visibilityTracker.GetTestAccessor().TriggerCallbacks(buffer) Assert.True(action1Called) Assert.True(action2Called) End Using End Sub End Class End Namespace