diff --git a/src/Tests/Testing.Common/Testing/CodeVerifier.cs b/src/Tests/Testing.Common/Testing/CodeVerifier.cs index 14b81ef52a..c721edf68f 100644 --- a/src/Tests/Testing.Common/Testing/CodeVerifier.cs +++ b/src/Tests/Testing.Common/Testing/CodeVerifier.cs @@ -312,7 +312,12 @@ internal static (Document document, ImmutableArray expectedDoc for (int i = 0; i < additionalFiles.Length; i++) { Document additionalDocument = project.AddDocument(AppendNumberToFileName(options.DocumentName, i + 2), SourceText.From(additionalFiles[i].Source)); - expectedDocuments.Add(new ExpectedDocument(additionalDocument.Id, additionalFiles[i].ExpectedSource)); + + string expectedSource = additionalFiles[i].ExpectedSource; + + if (expectedSource != null) + expectedDocuments.Add(new ExpectedDocument(additionalDocument.Id, expectedSource)); + project = additionalDocument.Project; } diff --git a/src/Tests/Testing.Common/Testing/CompilerDiagnosticFixVerifier.cs b/src/Tests/Testing.Common/Testing/CompilerDiagnosticFixVerifier.cs index 50776256ac..609c946a05 100644 --- a/src/Tests/Testing.Common/Testing/CompilerDiagnosticFixVerifier.cs +++ b/src/Tests/Testing.Common/Testing/CompilerDiagnosticFixVerifier.cs @@ -180,7 +180,7 @@ public async Task VerifyNoFixAsync( using (Workspace workspace = new AdhocWorkspace()) { - (Document document, ImmutableArray expectedDocuments) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options); + (Document document, ImmutableArray _) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options); Compilation compilation = await document.Project.GetCompilationAsync(cancellationToken); diff --git a/src/Tests/Testing.Common/Testing/DiagnosticVerifier.cs b/src/Tests/Testing.Common/Testing/DiagnosticVerifier.cs index ca1ca9063f..213c752807 100644 --- a/src/Tests/Testing.Common/Testing/DiagnosticVerifier.cs +++ b/src/Tests/Testing.Common/Testing/DiagnosticVerifier.cs @@ -73,6 +73,9 @@ public async Task VerifyDiagnosticAsync( { VerifyDiagnostics(data, analyzer, expectedDiagnostics, diagnostics, cancellationToken); } + + if (expectedDocuments.Any()) + await VerifyAdditionalDocumentsAsync(document.Project, expectedDocuments, cancellationToken); } static IEnumerable FilterDiagnostics( @@ -119,7 +122,7 @@ public async Task VerifyNoDiagnosticAsync( using (Workspace workspace = new AdhocWorkspace()) { - (Document document, ImmutableArray expectedDocuments) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options, data.Descriptor); + (Document document, ImmutableArray _) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options, data.Descriptor); SyntaxTree tree = await document.GetSyntaxTreeAsync(); @@ -342,7 +345,7 @@ private async Task VerifyNoFixAsync( using (Workspace workspace = new AdhocWorkspace()) { - (Document document, ImmutableArray expectedDocuments) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options, data.Descriptor); + (Document document, ImmutableArray _) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options, data.Descriptor); Compilation compilation = await document.Project.GetCompilationAsync(cancellationToken); diff --git a/src/Tests/Testing.Common/Testing/RefactoringVerifier.cs b/src/Tests/Testing.Common/Testing/RefactoringVerifier.cs index 2cd475a50f..319449c3f1 100644 --- a/src/Tests/Testing.Common/Testing/RefactoringVerifier.cs +++ b/src/Tests/Testing.Common/Testing/RefactoringVerifier.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -99,6 +100,9 @@ public async Task VerifyRefactoringAsync( VerifyNoNewCompilerDiagnostics(compilerDiagnostics, newCompilerDiagnostics, options); await VerifyExpectedDocument(expected, document, cancellationToken); + + if (expectedDocuments.Any()) + await VerifyAdditionalDocumentsAsync(document.Project, expectedDocuments, cancellationToken); } } } @@ -128,7 +132,7 @@ public async Task VerifyNoRefactoringAsync( using (Workspace workspace = new AdhocWorkspace()) { - (Document document, ImmutableArray expectedDocuments) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options); + (Document document, ImmutableArray _) = CreateDocument(workspace.CurrentSolution, data.Source, data.AdditionalFiles, options); SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken);