Skip to content

Commit af41d67

Browse files
Use Assert.Empty
1 parent 390b425 commit af41d67

File tree

18 files changed

+51
-51
lines changed

18 files changed

+51
-51
lines changed

src/EditorFeatures/Test/Collections/Immutable/Maps/MapTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void TestRemove()
7676
Assert.Equal(1, map.Count);
7777

7878
map = map.Remove("5");
79-
Assert.Equal(0, map.Count);
79+
Assert.Empty(map);
8080
}
8181

8282
[Fact]
@@ -116,7 +116,7 @@ public void TestPathology()
116116
Assert.Equal(1, map.Count);
117117

118118
map = map.Remove("5");
119-
Assert.Equal(0, map.Count);
119+
Assert.Empty(map);
120120
}
121121

122122
private class PathologicalComparer<T> : IEqualityComparer<T>

src/EditorFeatures/Test/Extensions/CollectionExtensionsTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public void PushReverse1()
2121
Assert.Equal(1, stack.Pop());
2222
Assert.Equal(2, stack.Pop());
2323
Assert.Equal(3, stack.Pop());
24-
Assert.Equal(0, stack.Count);
24+
Assert.Empty(stack);
2525
}
2626

2727
[Fact]
2828
public void PushReverse2()
2929
{
3030
var stack = new Stack<int>();
3131
stack.PushReverse(Array.Empty<int>());
32-
Assert.Equal(0, stack.Count);
32+
Assert.Empty(stack);
3333
}
3434

3535
[Fact]
@@ -41,6 +41,6 @@ public void PushReverse3()
4141
Assert.Equal(1, stack.Pop());
4242
Assert.Equal(2, stack.Pop());
4343
Assert.Equal(3, stack.Pop());
44-
Assert.Equal(0, stack.Count);
44+
Assert.Empty(stack);
4545
}
4646
}

src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.TestContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public async Task<MetadataAsSourceFile> GenerateSourceAsync(
104104
// Get an ISymbol corresponding to the metadata name
105105
var compilation = await project.GetRequiredCompilationAsync(CancellationToken.None);
106106
var diagnostics = compilation.GetDiagnostics().ToArray();
107-
Assert.Equal(0, diagnostics.Length);
107+
Assert.Empty(diagnostics);
108108
var symbol = await ResolveSymbolAsync(symbolMetadataName, compilation);
109109
Contract.ThrowIfNull(symbol);
110110

@@ -172,7 +172,7 @@ public void Dispose()
172172
{
173173
compilation = await this.DefaultProject.GetRequiredCompilationAsync(CancellationToken.None);
174174
var diagnostics = compilation.GetDiagnostics().ToArray();
175-
Assert.Equal(0, diagnostics.Length);
175+
Assert.Empty(diagnostics);
176176
}
177177

178178
foreach (var reference in compilation.References)

src/EditorFeatures/Test2/CodeFixes/CodeFixServiceTests.vb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
7878
(Await document.GetSyntaxRootAsync()).FullSpan,
7979
CancellationToken.None)
8080

81-
Assert.Equal(0, fixes.Length)
81+
Assert.Empty(fixes)
8282

8383
' Verify available codefix with a global fixer + a project fixer
8484
' We will use this assembly as a project fixer provider.
@@ -102,7 +102,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
102102
(Await document.GetSyntaxRootAsync()).FullSpan,
103103
CancellationToken.None)
104104

105-
Assert.Equal(0, fixes.Length)
105+
Assert.Empty(fixes)
106106
End Using
107107
End Function
108108

@@ -150,7 +150,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
150150
(Await document.GetSyntaxRootAsync()).FullSpan,
151151
CancellationToken.None)
152152

153-
Assert.Equal(0, fixes.Length)
153+
Assert.Empty(fixes)
154154

155155
' Verify no codefix with a global fixer + a project fixer
156156
' We will use this assembly as a project fixer provider.
@@ -165,7 +165,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.CodeFixes.UnitTests
165165
(Await document.GetSyntaxRootAsync()).FullSpan,
166166
CancellationToken.None)
167167

168-
Assert.Equal(0, fixes.Length)
168+
Assert.Empty(fixes)
169169
End Using
170170
End Function
171171

src/EditorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
266266
includeSuppressedDiagnostics:=False, includeLocalDocumentDiagnostics:=True, includeNonLocalDocumentDiagnostics:=True, CancellationToken.None).Result
267267

268268
If diagnostics Is Nothing Then
269-
Assert.Equal(0, actualDiagnostics.Length)
269+
Assert.Empty(actualDiagnostics)
270270
Else
271271
Dim expectedDiagnostics = GetExpectedDiagnostics(workspace, diagnostics)
272272

src/EditorFeatures/Test2/Diagnostics/DiagnosticServiceTests.vb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
300300
project = project.WithCompilationOptions(newCompilationOptions)
301301
document = project.Documents.Single()
302302
diagnostics = Await GetDiagnosticsForSpanAsync(diagnosticService, document, span)
303-
Assert.Equal(0, diagnostics.Length)
303+
Assert.Empty(diagnostics)
304304

305305
Dim changeSeverityDiagOptions = New Dictionary(Of String, ReportDiagnostic)
306306
changeSeverityDiagOptions.Add(workspaceDiagnosticAnalyzer.DiagDescriptor.Id, ReportDiagnostic.Error)
@@ -350,7 +350,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
350350

351351
Dim hostAnalyzers = solution.SolutionState.Analyzers
352352
Dim workspaceDescriptors = hostAnalyzers.GetDiagnosticDescriptorsPerReference(diagnosticService.AnalyzerInfoCache)
353-
Assert.Equal(0, workspaceDescriptors.Count)
353+
Assert.Empty(workspaceDescriptors)
354354

355355
Dim descriptors1 = hostAnalyzers.GetDiagnosticDescriptorsPerReference(diagnosticService.AnalyzerInfoCache, p1)
356356
Assert.Equal("XX0001", descriptors1.Single().Value.Single().Id)
@@ -494,14 +494,14 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
494494
Dim descriptorsMap = solution.SolutionState.Analyzers.GetDiagnosticDescriptorsPerReference(diagnosticService.AnalyzerInfoCache, project)
495495
Assert.Equal(1, descriptorsMap.Count)
496496
Dim descriptors = descriptorsMap.First().Value
497-
Assert.Equal(0, descriptors.Length)
497+
Assert.Empty(descriptors)
498498

499499
Dim document = project.Documents.Single()
500500

501501
Dim incrementalAnalyzer = diagnosticService.CreateIncrementalAnalyzer(workspace)
502502
Dim diagnostics = Await GetDiagnosticsForDocumentAsync(diagnosticService, document)
503503

504-
Assert.Equal(0, diagnostics.Length)
504+
Assert.Empty(diagnostics)
505505
End Using
506506
End Function
507507

@@ -534,7 +534,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
534534
Dim incrementalAnalyzer = diagnosticService.CreateIncrementalAnalyzer(workspace)
535535
Dim root = Await document.GetSyntaxRootAsync().ConfigureAwait(False)
536536
Dim diagnostics = Await GetDiagnosticsForSpanAsync(diagnosticService, document, root.FullSpan)
537-
Assert.Equal(0, diagnostics.Length)
537+
Assert.Empty(diagnostics)
538538

539539
diagnostics = Await diagnosticService.GetDiagnosticsForIdsAsync(
540540
project.Solution, projectId:=Nothing, documentId:=Nothing, diagnosticIds:=Nothing, shouldIncludeAnalyzer:=Nothing,
@@ -2096,7 +2096,7 @@ class MyClass
20962096
Dim document = project.Documents.Single()
20972097
Dim diagnostics = Await GetDiagnosticsForDocumentAsync(diagnosticService, document)
20982098

2099-
Assert.Equal(0, diagnostics.Length)
2099+
Assert.Empty(diagnostics)
21002100
End Using
21012101
End Function
21022102

@@ -2237,7 +2237,7 @@ class C
22372237
Dim diagnostics = Await diagnosticService.GetDiagnosticsForIdsAsync(
22382238
project.Solution, project.Id, documentId:=Nothing, diagnosticIds:=Nothing, shouldIncludeAnalyzer:=Nothing,
22392239
includeSuppressedDiagnostics:=False, includeLocalDocumentDiagnostics:=True, includeNonLocalDocumentDiagnostics:=True, CancellationToken.None)
2240-
Assert.Equal(0, diagnostics.Length)
2240+
Assert.Empty(diagnostics)
22412241
End Using
22422242
End Function
22432243

src/EditorFeatures/TestUtilities/Rename/RenamerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected async Task TestRenameDocument(
9999
}
100100

101101
AssertEx.EqualOrDiff(endDocument.Text, (await updatedDocument.GetTextAsync()).ToString());
102-
Assert.Equal(0, remainingErrors.Count);
102+
Assert.Empty(remainingErrors);
103103
}
104104
}
105105

src/EditorFeatures/VisualBasicTest/Recommendations/RecommendationTestHelpers.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations
147147
.OrderBy(Function(recommendation) recommendation) _
148148
.ToArray()
149149

150-
Assert.Equal(0, recommendedKeywords.Length)
150+
Assert.Empty(recommendedKeywords)
151151
End Sub
152152

153153
Private Function GetSourceCodeKind(testSource As XElement) As SourceCodeKind

src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalFunctionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ int G()
4141
string typeName;
4242
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
4343
Assert.NotNull(assembly);
44-
Assert.Equal(0, assembly.Count);
45-
Assert.Equal(0, locals.Count);
44+
Assert.Empty(assembly);
45+
Assert.Empty(locals);
4646
locals.Free();
4747
});
4848
}

src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static void M()
4646
string typeName;
4747
var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
4848
Assert.NotNull(assembly);
49-
Assert.Equal(0, assembly.Count);
50-
Assert.Equal(0, locals.Count);
49+
Assert.Empty(assembly);
50+
Assert.Empty(locals);
5151
locals.Free();
5252
});
5353
}
@@ -2491,7 +2491,7 @@ static void M(A a, B b, C c)
24912491
Diagnostic(ErrorCode.ERR_NoTypeDef).WithArguments("A", "Comp1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(1, 1)
24922492
]);
24932493

2494-
Assert.Equal(0, locals.Count);
2494+
Assert.Empty(locals);
24952495
locals.Free();
24962496
});
24972497
}
@@ -2535,7 +2535,7 @@ static void M<T>(object o) where T : I
25352535
Diagnostic(ErrorCode.ERR_NoTypeDef).WithArguments("I", "Comp1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(1, 1)
25362536
]);
25372537

2538-
Assert.Equal(0, locals.Count);
2538+
Assert.Empty(locals);
25392539
locals.Free();
25402540
});
25412541
}
@@ -5116,7 +5116,7 @@ private static void GetLocals(RuntimeInstance runtime, string methodName, bool a
51165116
Assert.NotNull(assembly);
51175117
if (count == 0)
51185118
{
5119-
Assert.Equal(0, assembly.Count);
5119+
Assert.Empty(assembly);
51205120
}
51215121
else
51225122
{
@@ -5156,7 +5156,7 @@ private static void GetLocals(RuntimeInstance runtime, string methodName, Method
51565156
Assert.NotNull(assembly);
51575157
if (count == 0)
51585158
{
5159-
Assert.Equal(0, assembly.Count);
5159+
Assert.Empty(assembly);
51605160
}
51615161
else
51625162
{

0 commit comments

Comments
 (0)