Skip to content

Commit 54225ff

Browse files
committed
Fix xUnit2013 by using Assert.Empty where appropriate
1 parent b9a9fdf commit 54225ff

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void TestProperties()
6767
var wrapperWithModifiedModifiers = wrapper.WithModifiers(newModifiers);
6868
Assert.NotNull(wrapperWithModifiedModifiers.SyntaxNode);
6969
Assert.NotEqual(syntaxNode.Modifiers, wrapperWithModifiedModifiers.Modifiers);
70-
Assert.Equal(0, wrapperWithModifiedModifiers.Modifiers.Count);
70+
Assert.Empty(wrapperWithModifiedModifiers.Modifiers);
7171

7272
var newReturnType = SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.BoolKeyword));
7373
var wrapperWithModifiedReturnType = wrapper.WithReturnType(newReturnType);
@@ -86,25 +86,25 @@ public void TestProperties()
8686
var wrapperWithModifiedTypeParameterList = wrapper.WithTypeParameterList(newTypeParameterList);
8787
Assert.NotNull(wrapperWithModifiedTypeParameterList.SyntaxNode);
8888
Assert.NotSame(syntaxNode.TypeParameterList, wrapperWithModifiedTypeParameterList.TypeParameterList);
89-
Assert.Equal(0, wrapperWithModifiedTypeParameterList.TypeParameterList.Parameters.Count);
89+
Assert.Empty(wrapperWithModifiedTypeParameterList.TypeParameterList.Parameters);
9090

9191
var newParameterList = SyntaxFactory.ParameterList();
9292
var wrapperWithModifiedParameterList = wrapper.WithParameterList(newParameterList);
9393
Assert.NotNull(wrapperWithModifiedParameterList.SyntaxNode);
9494
Assert.NotSame(syntaxNode.ParameterList, wrapperWithModifiedParameterList.ParameterList);
95-
Assert.Equal(0, wrapperWithModifiedParameterList.ParameterList.Parameters.Count);
95+
Assert.Empty(wrapperWithModifiedParameterList.ParameterList.Parameters);
9696

9797
var newConstraintClauses = SyntaxFactory.List<TypeParameterConstraintClauseSyntax>();
9898
var wrapperWithModifiedConstraintClauses = wrapper.WithConstraintClauses(newConstraintClauses);
9999
Assert.NotNull(wrapperWithModifiedConstraintClauses.SyntaxNode);
100100
Assert.NotEqual(syntaxNode.ConstraintClauses, wrapperWithModifiedConstraintClauses.ConstraintClauses);
101-
Assert.Equal(0, wrapperWithModifiedConstraintClauses.ConstraintClauses.Count);
101+
Assert.Empty(wrapperWithModifiedConstraintClauses.ConstraintClauses);
102102

103103
var newBody = SyntaxFactory.Block();
104104
var wrapperWithModifiedBody = wrapper.WithBody(newBody);
105105
Assert.NotNull(wrapperWithModifiedBody.SyntaxNode);
106106
Assert.Equal(SyntaxKind.Block, wrapperWithModifiedBody.Body.Kind());
107-
Assert.Equal(0, wrapperWithModifiedBody.Body.Statements.Count);
107+
Assert.Empty(wrapperWithModifiedBody.Body.Statements);
108108

109109
var newExpressionBody = SyntaxFactory.ArrowExpressionClause(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression));
110110
var wrapperWithModifiedExpressionBody = wrapper.WithExpressionBody(newExpressionBody);

StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/SharedPoolsTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void TestStackPool()
7171
Assert.NotEqual(0, collection.Count);
7272
}
7373

74-
Assert.Equal(0, collection.Count);
74+
Assert.Empty(collection);
7575
}
7676

7777
[Fact]
@@ -90,7 +90,7 @@ public void TestQueuePool()
9090
Assert.NotEqual(0, collection.Count);
9191
}
9292

93-
Assert.Equal(0, collection.Count);
93+
Assert.Empty(collection);
9494
}
9595

9696
[Fact]
@@ -109,7 +109,7 @@ public void TestHashSetPool()
109109
Assert.NotEqual(0, collection.Count);
110110
}
111111

112-
Assert.Equal(0, collection.Count);
112+
Assert.Empty(collection);
113113
}
114114

115115
[Fact]
@@ -128,7 +128,7 @@ public void TestDictionaryPool()
128128
Assert.NotEqual(0, collection.Count);
129129
}
130130

131-
Assert.Equal(0, collection.Count);
131+
Assert.Empty(collection);
132132
}
133133

134134
[Fact]
@@ -147,7 +147,7 @@ public void TestListPool()
147147
Assert.NotEqual(0, collection.Count);
148148
}
149149

150-
Assert.Equal(0, collection.Count);
150+
Assert.Empty(collection);
151151
}
152152

153153
[Fact]
@@ -182,17 +182,17 @@ public void TestClearAndFreeLarge()
182182
// HashSet<int>
183183
var set = new HashSet<int>(Enumerable.Range(0, 1024));
184184
SharedPools.Default<HashSet<int>>().ClearAndFree(set);
185-
Assert.Equal(0, set.Count);
185+
Assert.Empty(set);
186186

187187
// Stack<int>
188188
var stack = new Stack<int>(Enumerable.Range(0, 1024));
189189
SharedPools.Default<Stack<int>>().ClearAndFree(stack);
190-
Assert.Equal(0, stack.Count);
190+
Assert.Empty(stack);
191191

192192
// Queue<int>
193193
var queue = new Queue<int>(Enumerable.Range(0, 1024));
194194
SharedPools.Default<Queue<int>>().ClearAndFree(queue);
195-
Assert.Equal(0, queue.Count);
195+
Assert.Empty(queue);
196196

197197
// Dictionary<int, int> **This one doesn't go back in the pool!**
198198
var dictionary = Enumerable.Range(0, 1024).ToDictionary(i => i);
@@ -203,7 +203,7 @@ public void TestClearAndFreeLarge()
203203
var list = new List<int>(Enumerable.Range(0, 1024));
204204
Assert.True(list.Capacity >= 1024);
205205
SharedPools.Default<List<int>>().ClearAndFree(list);
206-
Assert.Equal(0, list.Count);
206+
Assert.Empty(list);
207207
Assert.True(list.Capacity < 1024);
208208
}
209209

StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public abstract class SeparatedSyntaxListWrapperTestBase
1414
public void TestBasicProperties()
1515
{
1616
var list = this.CreateList();
17-
Assert.Equal(0, list.Count);
17+
Assert.Empty(list);
1818
Assert.Equal(0, list.SeparatorCount);
1919
Assert.Equal(default(SeparatedSyntaxList<SyntaxNode>).FullSpan, list.FullSpan);
2020
Assert.Equal(default(SeparatedSyntaxList<SyntaxNode>).Span, list.Span);
@@ -26,7 +26,7 @@ public void TestBasicProperties()
2626
{
2727
Assert.IsAssignableFrom<SeparatedSyntaxList<SyntaxNode>>(list.UnderlyingList);
2828
var underlyingList = (SeparatedSyntaxList<SyntaxNode>)list.UnderlyingList;
29-
Assert.Equal(0, list.Count);
29+
Assert.Empty(list);
3030
}
3131
}
3232

StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void VerifySettingsDefaults()
2727
Assert.Equal("PlaceholderCompany", styleCopSettings.DocumentationRules.CompanyName);
2828
Assert.Equal("Copyright (c) PlaceholderCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
2929
Assert.True(styleCopSettings.NamingRules.AllowCommonHungarianPrefixes);
30-
Assert.Equal(0, styleCopSettings.NamingRules.AllowedHungarianPrefixes.Length);
30+
Assert.Empty(styleCopSettings.NamingRules.AllowedHungarianPrefixes);
3131

3232
Assert.NotNull(styleCopSettings.OrderingRules);
3333
Assert.Equal(UsingDirectivesPlacement.InsideNamespace, styleCopSettings.OrderingRules.UsingDirectivesPlacement);

0 commit comments

Comments
 (0)