Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable xunit1024 #34512

Merged
merged 68 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
e8331c7
Enable analyzer rule xUnit1024
alexvy86 Apr 3, 2020
8e80f75
Remove redundant test in System.Text.Json
alexvy86 Apr 3, 2020
e79f8a0
Rename test methods in System.Text.Json
alexvy86 Apr 3, 2020
42742c0
Private methods -> local functions in System.Text.Json
alexvy86 Apr 5, 2020
f39c409
Rename test methods in System.ComponentModel.Annotations
alexvy86 Apr 3, 2020
a25a75f
Rename test methods in System.Collections.Immutable
alexvy86 Apr 3, 2020
eb5596a
Rename test methods in System.Globalization
alexvy86 Apr 3, 2020
f1a4c49
Rename test methods in System.Runtime.Extensions
alexvy86 Apr 4, 2020
6a6b739
Rename test methods in System.Private.Uri
alexvy86 Apr 4, 2020
f773c3b
Rename test methods in System.Runtime.WindowsRuntime.UI.Xaml
alexvy86 Apr 4, 2020
d04193c
Rename test methods in System.Security.Cryptography.X509Certificates
alexvy86 Apr 4, 2020
d7e6307
Rename test methods in System.Reflection
alexvy86 Apr 4, 2020
093eb26
Remove redundant test in System.IO.FileSystem.Watcher
alexvy86 Apr 4, 2020
7e9cece
Rename test methods in System.IO.FileSystem.Watcher
alexvy86 Apr 4, 2020
87bae0f
Rename test methods in System.Composition.Runtime
alexvy86 Apr 4, 2020
999eac4
Rename test methods in System.Drawing.Primitives
alexvy86 Apr 4, 2020
9f3a8ae
Rename test methods in System.Reflection.Emit
alexvy86 Apr 4, 2020
e40ca18
Rename test methods in System.Text.RegularExpressions
alexvy86 Apr 4, 2020
d02ae8f
Private methods -> local functions in System.Threading.Tasks.Parallel
alexvy86 Apr 4, 2020
b09750a
Rename test methods in System.Threading.Tasks.Parallel
alexvy86 Apr 4, 2020
f495e14
Rename test methods in System.Threading.Tasks
alexvy86 Apr 4, 2020
2a840dc
Simplify tests in System.Threading
alexvy86 Apr 4, 2020
9ef7250
Rename test methods in System.Threading
alexvy86 Apr 4, 2020
8ac50b0
Rename test methods in Microsoft.VisualBasic.Core
alexvy86 Apr 4, 2020
b1c4fc2
Rename test methods in System.DirectoryServices.AccountManagement
alexvy86 Apr 4, 2020
670b4c0
Private methods -> local functions in System.Text.Encoding
alexvy86 Apr 4, 2020
a16535d
Rename test methods in System.Text.Encoding
alexvy86 Apr 4, 2020
7ba83ac
Rename test methods in System.Security.Cryptography.Primitives
alexvy86 Apr 4, 2020
baa632f
Rename test methods in System.Runtime.Numeric
alexvy86 Apr 4, 2020
2785d7b
Rename test methods in System.CodeDom.Tests
alexvy86 Apr 4, 2020
11769e0
Rename test methods in System.Reflection.Emit.ILGeneration
alexvy86 Apr 4, 2020
936f460
Rename test methods in System.Composition.AttributedModel
alexvy86 Apr 4, 2020
baea35c
Rename test methods in System.Data.DataSetExtensions
alexvy86 Apr 4, 2020
8291c07
Rename test methods in System.Runtime
alexvy86 Apr 4, 2020
4d7a3e3
Rename test methods in System.Runtime.InteropServices
alexvy86 Apr 4, 2020
e6d42ea
Remove redundant test in System.ServiceModel.Syndication
alexvy86 Apr 4, 2020
8c9fe5c
Rename test methods in System.ServiceModel.Syndication
alexvy86 Apr 4, 2020
ddf6d1a
Rename test methods in System.Data.Common
alexvy86 Apr 4, 2020
0e382d8
Rename test methods in System.Security.Cryptography.Xml
alexvy86 Apr 4, 2020
7c58e12
Private methods -> local functions in System.Security.Cryptography.Xml
alexvy86 Apr 4, 2020
8d58824
Simplify tests in System.Security.Cryptography.ProtectedData
alexvy86 Apr 4, 2020
7a35160
Replace private methods with local functions...
alexvy86 Apr 4, 2020
efc24fa
Rename test methods in System.Security.Cryptography.Algorithms
alexvy86 Apr 4, 2020
2c3d90b
Simplify tests code in System.Collections.Concurrent
alexvy86 Apr 5, 2020
a42b74b
Rename test methods in System.Drawing.Common
alexvy86 Apr 5, 2020
7d1b4aa
Rename test methods in System.Data.OleDb
alexvy86 Apr 5, 2020
fd046fd
Rename test methods in System.ComponentModel.TypeConverter
alexvy86 Apr 5, 2020
8791101
Rename test methods in System.Web.HttpUtility
alexvy86 Apr 5, 2020
d03b23d
Rename test methods in System.Linq
alexvy86 Apr 5, 2020
fbbd5a0
Private method -> local function in System.Linq
alexvy86 Apr 5, 2020
7c76599
Rename test methods in System.Memory
alexvy86 Apr 5, 2020
56d2e28
Rename test methods in System.IO.IsolatedStorage
alexvy86 Apr 5, 2020
f4785f5
Rename test methods in System.DirectoryServices.Protocols
alexvy86 Apr 5, 2020
fc70765
Rename test methods in System.Globalization.Extensions
alexvy86 Apr 5, 2020
57abd5a
Private methods -> local functions in System.Globalization.Extensions
alexvy86 Apr 5, 2020
a63dc26
Rename test methods in System.IO.Compression
alexvy86 Apr 5, 2020
20b357c
Rename test methods in System.Security.Cryptography.Encoding
alexvy86 Apr 5, 2020
f616b5f
Rename test methods in Microsoft.Win32.Registry
alexvy86 Apr 5, 2020
adc651f
Rename test methods in System.IO.UnmanagedMemoryStream
alexvy86 Apr 5, 2020
b4124d9
Rename test methods in System.Collections
alexvy86 Apr 5, 2020
98811f8
Rename test methods in System.Collections.Specialized
alexvy86 Apr 5, 2020
043f1de
Rename test methods in System.Private.Xml
alexvy86 Apr 5, 2020
98c89c3
Rename test methods in System.IO.FileSystem
alexvy86 Apr 5, 2020
e7b0bb7
Rename test methods in System.Diagnostics.StackTrace
alexvy86 Apr 5, 2020
194376e
Rename test methods in System.Diagnostics
alexvy86 Apr 6, 2020
e3e0049
Improve some test method renames
alexvy86 Apr 7, 2020
3d29c9f
Minor nit fixing
alexvy86 Apr 7, 2020
2f0bc0c
More improvements to test method names
alexvy86 Apr 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eng/CodeAnalysis.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
<Rule Id="SA1649" Action="None" /> <!-- File name should match first type name -->
</Rules>
<Rules AnalyzerId="xunit.analyzers" RuleNamespace="xunit.analyzers">
<Rule Id="xUnit1024" Action="None" /> <!-- Test methods cannot have overloads -->
<Rule Id="xUnit2013" Action="None" /> <!-- Do not use equality check to check for collection size. -->
<Rule Id="xUnit2017" Action="None" /> <!-- Do not use Contains() to check if a value exists in a collection -->
</Rules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ public static IEnumerable<object[]> RoundtripCompressDecompressOuterData
}

[Fact]
public async Task CompressDecompress_RoundTrip()
public async Task CompressDecompress_RoundTrip_BaseTests()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to see this test's name left as-is, and the method it delegates to instead be renamed to something like CompressDecompress_RoundTrip_OuterLoop. Same goes for the other similar cases here. My reason is "BaseTests" doesn't really speak to what the test is doing, plus this is the test that runs 99% of the time, and the one it delegates to is relegated to only running when we run "OuterLoop".

{
await CompressDecompress_RoundTrip(ReadWriteMode.SyncArray, chunkSize: 1, totalSize: 10, level: CompressionLevel.Fastest);
await CompressDecompress_RoundTrip(ReadWriteMode.SyncSpan, chunkSize: 1, totalSize: 10, level: CompressionLevel.Fastest);
Expand Down Expand Up @@ -711,7 +711,7 @@ public async Task CompressDecompress_RoundTrip(ReadWriteMode readWriteMode, int
}

[Fact]
public async Task Flush_RoundTrip()
public async Task Flush_RoundTrip_BaseTests()
{
if (FlushNoOps)
return;
Expand Down Expand Up @@ -773,7 +773,7 @@ public async Task Flush_RoundTrip(ReadWriteMode readWriteMode, int chunkSize, in
}

[Fact]
public async Task Flush_Consecutive()
public async Task Flush_Consecutive_BaseTests()
{
if (FlushNoOps)
return;
Expand Down Expand Up @@ -847,7 +847,7 @@ public async Task Flush_Consecutive(ReadWriteMode readWriteMode, int chunkSize,
}

[Fact]
public async Task Flush_BeforeFirstWrites()
public async Task Flush_BeforeFirstWrites_BaseTests()
{
if (FlushNoOps)
return;
Expand Down Expand Up @@ -1168,7 +1168,7 @@ private async Task CopyTo_Roundtrip_OutputMatchesInput_Verify(byte[] expectedDec
[Theory]
[InlineData(CompressionMode.Compress)]
[InlineData(CompressionMode.Decompress)]
public void BaseStream(CompressionMode mode)
public void BaseStreamTest(CompressionMode mode)
{
using (var baseStream = new MemoryStream())
using (var compressor = CreateStream(baseStream, mode))
Expand Down
20 changes: 10 additions & 10 deletions src/libraries/Common/tests/Tests/System/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ public static void CompareOrdinal_NegativeLength_ThrowsArgumentOutOfRangeExcepti
[InlineData("", "", true)]
[InlineData("", "hello", false)]
[InlineData("Hello", "", true)]
public static void Contains(string s, string value, bool expected)
public static void Contains_String(string s, string value, bool expected)
{
Assert.Equal(expected, s.Contains(value));
Assert.Equal(expected, s.AsSpan().Contains(value.AsSpan(), StringComparison.Ordinal));
Expand Down Expand Up @@ -1666,7 +1666,7 @@ public static void MakeSureNoSequenceEqualChecksGoOutOfRange_Char()
[InlineData("Hello", "llo" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false)]
[InlineData("", "", StringComparison.OrdinalIgnoreCase, true)]
[InlineData("", "a", StringComparison.OrdinalIgnoreCase, false)]
public static void EndsWith(string s, string value, StringComparison comparisonType, bool expected)
public static void EndsWith_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static void EndsWith_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected)
public static void EndsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected)

{
if (comparisonType == StringComparison.CurrentCulture)
{
Expand Down Expand Up @@ -2482,7 +2482,7 @@ public static void GetHashCode_EmbeddedNull_ReturnsDifferentHashCodes()
[InlineData("", "", StringComparison.OrdinalIgnoreCase, true)]
[InlineData("123", 123, StringComparison.OrdinalIgnoreCase, false)] // Not a string
[InlineData("\0AAAAAAAAA", "\0BBBBBBBBBBBB", StringComparison.OrdinalIgnoreCase, false)]
public static void Equals(string s1, object obj, StringComparison comparisonType, bool expected)
public static void EqualsTest(string s1, object obj, StringComparison comparisonType, bool expected)
{
string s2 = obj as string;
if (s1 != null)
Expand Down Expand Up @@ -4518,7 +4518,7 @@ public static void Remove_Invalid()
"Mauris nulla sapien, convallis et quam quis, accumsan sodales mi. Praesent dapibus urna fermentum, sollicitudin posuere.",
'e', 'E',
"LorEm ipsum dolor sit amEt, consEctEtur adipiscing Elit. Proin maximus convallis luctus. Curabitur porttitor mi blandit tEllus maximus varius. " +
"Mauris nulla sapiEn, convallis Et quam quis, accumsan sodalEs mi. PraEsEnt dapibus urna fErmEntum, sollicitudin posuErE.")]
"Mauris nulla sapiEn, convallis Et quam quis, accumsan sodalEs mi. PraEsEnt dapibus urna fErmEntum, sollicitudin posuErE.")]
public static void Replace_Char_Char(string s, char oldChar, char newChar, string expected)
{
Assert.Equal(expected, s.Replace(oldChar, newChar));
Expand Down Expand Up @@ -4639,7 +4639,7 @@ public void Replace_EmptyOldValue_ThrowsArgumentException()
[InlineData("Hello", SoftHyphen + "Hel", StringComparison.OrdinalIgnoreCase, false)]
[InlineData("", "", StringComparison.OrdinalIgnoreCase, true)]
[InlineData("", "hello", StringComparison.OrdinalIgnoreCase, false)]
public static void StartsWith(string s, string value, StringComparison comparisonType, bool expected)
public static void StartsWith_WithExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static void StartsWith_WithExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected)
public static void StartsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected)

{
if (comparisonType == StringComparison.CurrentCulture)
{
Expand Down Expand Up @@ -5125,7 +5125,7 @@ public static void SameSpanToLower()
Assert.Equal(expected, s1.ToLower(CultureInfo.CurrentCulture).ToArray());
Assert.Equal(expected, s1.ToLowerInvariant().ToArray());
{
AssertExtensions.AssertThrows<InvalidOperationException, char>(a, a =>
AssertExtensions.AssertThrows<InvalidOperationException, char>(a, a =>
{
ReadOnlySpan<char> source = a;
Span<char> destination = a;
Expand Down Expand Up @@ -5158,7 +5158,7 @@ public static void ToLowerOverlapping()
var source = new ReadOnlySpan<char>(a, 1, 3);

AssertExtensions.AssertThrows<InvalidOperationException,char>(source, source =>
{
{
var destination = new Span<char>(a, 3, 3);
source.ToLower(destination, CultureInfo.CurrentCulture);
});
Expand Down Expand Up @@ -5222,7 +5222,7 @@ public static void LengthMismatchToLower()
}

[Fact]
public static void ToLower()
public static void ToLower_2()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the other ToLower test this is conflicting with? "ToLower_2" isn't descriptive about what makes this test different from a presumed "ToLower_1", so we should either pick descriptive names or combine the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's this one, using strings + Span instead of char[] + Span throughout. How about naming them ToLower_String and ToLower_CharArray?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about naming them ToLower_String and ToLower_CharArray?

Sounds fine. Thanks.

{
var expectedSource = new char[3] { 'a', 'B', 'c' };
var expectedDestination = new char[3] { 'a', 'b', 'c' };
Expand Down Expand Up @@ -5434,7 +5434,7 @@ public static void LengthMismatchToUpper()
}

[Fact]
public static void ToUpper()
public static void ToUpper_2()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

{
var expectedSource = new char[3] { 'a', 'B', 'c' };
var expectedDestination = new char[3] { 'A', 'B', 'C' };
Expand Down Expand Up @@ -5544,7 +5544,7 @@ public static void Test_ToUpper_Culture(string actual, string expected, CultureI
[Theory]
[InlineData("")]
[InlineData("hello")]
public static void ToString(string s)
public static void ToStringTest(string s)
{
Assert.Same(s, s.ToString());
Assert.Same(s, s.ToString(null));
Expand Down
Loading