提交 09b56d19 编写于 作者: C CyrusNajmabadi

Update tests to validate that projects/references are added properly.

上级 231e24e6
...@@ -280,6 +280,10 @@ public override bool CanApplyChange(ApplyChangesKind feature) ...@@ -280,6 +280,10 @@ public override bool CanApplyChange(ApplyChangesKind feature)
case ApplyChangesKind.ChangeAdditionalDocument: case ApplyChangesKind.ChangeAdditionalDocument:
return this.CanApplyChangeDocument; return this.CanApplyChangeDocument;
case ApplyChangesKind.AddProjectReference:
case ApplyChangesKind.AddMetadataReference:
return true;
default: default:
return false; return false;
} }
......
...@@ -53,11 +53,17 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics ...@@ -53,11 +53,17 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
Dim codeActions = diagnosticAndFix.Item2.Fixes.Select(Function(f) f.Action).ToList() Dim codeActions = diagnosticAndFix.Item2.Fixes.Select(Function(f) f.Action).ToList()
codeActions = MassageActions(codeActions) codeActions = MassageActions(codeActions)
Dim codeAction = codeActions(codeActionIndex) Dim codeAction = codeActions(codeActionIndex)
Dim operations = Await codeAction.GetOperationsAsync(CancellationToken.None)
Dim edit = operations.OfType(Of ApplyChangesOperation)().First()
Dim oldSolution = workspace.CurrentSolution Dim oldSolution = workspace.CurrentSolution
Dim updatedSolution = edit.ChangedSolution Dim operations = Await codeAction.GetOperationsAsync(CancellationToken.None)
For Each operation In operations
If operation.ApplyDuringTests Then
operation.Apply(workspace, CancellationToken.None)
End If
Next
Dim updatedSolution = workspace.CurrentSolution
verifySolutions?.Invoke(oldSolution, updatedSolution) verifySolutions?.Invoke(oldSolution, updatedSolution)
......
...@@ -20,6 +20,8 @@ public AddMetadataReferenceCodeActionOperation(DocumentId documentId, PortableEx ...@@ -20,6 +20,8 @@ public AddMetadataReferenceCodeActionOperation(DocumentId documentId, PortableEx
_reference = reference; _reference = reference;
} }
internal override bool ApplyDuringTests => true;
public override void Apply(Workspace workspace, CancellationToken cancellationToken) public override void Apply(Workspace workspace, CancellationToken cancellationToken)
{ {
var service = workspace.Services.GetService<IAddImportUndoService>(); var service = workspace.Services.GetService<IAddImportUndoService>();
......
...@@ -21,6 +21,8 @@ private class AddProjectReferenceCodeActionOperation : CodeActionOperation ...@@ -21,6 +21,8 @@ private class AddProjectReferenceCodeActionOperation : CodeActionOperation
_toProjectId = toProjectId; _toProjectId = toProjectId;
} }
internal override bool ApplyDuringTests => true;
public override void Apply(Workspace workspace, CancellationToken cancellationToken) public override void Apply(Workspace workspace, CancellationToken cancellationToken)
{ {
var service = workspace.Services.GetService<IAddImportUndoService>(); var service = workspace.Services.GetService<IAddImportUndoService>();
......
...@@ -20,7 +20,7 @@ internal interface IAddImportUndoService : IWorkspaceService ...@@ -20,7 +20,7 @@ internal interface IAddImportUndoService : IWorkspaceService
CancellationToken cancellationToken); CancellationToken cancellationToken);
} }
[ExportWorkspaceService(typeof(IWorkspaceService)), Shared] [ExportWorkspaceService(typeof(IAddImportUndoService)), Shared]
internal class DefaultAddImportUndoService : IAddImportUndoService internal class DefaultAddImportUndoService : IAddImportUndoService
{ {
public bool TryAddMetadataReference( public bool TryAddMetadataReference(
......
...@@ -41,6 +41,8 @@ public Solution ChangedSolution ...@@ -41,6 +41,8 @@ public Solution ChangedSolution
get { return _changedSolution; } get { return _changedSolution; }
} }
internal override bool ApplyDuringTests => true;
public override void Apply(Workspace workspace, CancellationToken cancellationToken) public override void Apply(Workspace workspace, CancellationToken cancellationToken)
{ {
this.Apply(workspace, new ProgressTracker(), cancellationToken); this.Apply(workspace, new ProgressTracker(), cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册