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 3 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 @@ -111,7 +111,7 @@ public static void CustomEncoderCantOverrideHtml(string message, string expected
}

[Fact]
public static void Equals()
public static void EqualsTest()
{
string message = "message";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void Parse_WithinRange_Signed_ReturnsWithCorrectType(Type expected

[Theory]
[MemberData(nameof(Parse_WithinRange_Signed))]
public static void Parse_WithinRange_ReturnsExpected(object expected, long value, string name)
public static void Parse_WithinRange_Signed_ReturnsExpected(object expected, long value, string name)
{
string json = $"{{ \"{ name }\" : { value } }}";
SimpleTestClass result = JsonSerializer.Deserialize<SimpleTestClass>(json);
Expand All @@ -90,7 +90,7 @@ public static void Parse_WithinRange_Unsigned_ReturnsWithCorrectType(Type expect

[Theory]
[MemberData(nameof(Parse_WithinRange_Unsigned))]
public static void Parse_WithinRange_ReturnsExpected(object expected, ulong value, string name)
public static void Parse_WithinRange_Unsigned_ReturnsExpected(object expected, ulong value, string name)
{
string json = $"{{ \"{ name }\" : { value } }}";
SimpleTestClass result = JsonSerializer.Deserialize<SimpleTestClass>(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,16 +997,6 @@ public static void ReadKeyValuePairOfList()
Assert.Equal(3, input.Value[2]);
}

[Fact]
public static void ReadKeyValuePairOfKeyValuePair()
Copy link
Member

Choose a reason for hiding this comment

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

Was this a dup? Wondering why it's being deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, see the first bullet point of the second set in the description, there's a Theory testing the exact same thing, and the data that this method uses is already part of the InlineData of the Theory.

{
KeyValuePair<string, KeyValuePair<int, int>> input = JsonSerializer.Deserialize<KeyValuePair<string, KeyValuePair<int, int>>>(@"{""Key"":""Key"", ""Value"":{""Key"":1, ""Value"":2}}");

Assert.Equal("Key", input.Key);
Assert.Equal(1, input.Value.Key);
Assert.Equal(2, input.Value.Value);
}

[Theory]
[InlineData(@"{""Key"":""Key"", ""Value"":{""Key"":1, ""Value"":2}}")]
[InlineData(@"{""Key"":""Key"", ""Value"":{""Value"":2, ""Key"":1}}")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,11 +1336,11 @@ public static void TestingStringsConversionToGuid(string testString, string expe
[MemberData(nameof(JsonGuidTestData.ValidGuidTests), MemberType = typeof(JsonGuidTestData))]
public static void TryGetGuid_HasValueSequence_RetrievesGuid(string testString, string expectedString)
{
TryGetGuid_HasValueSequence_RetrievesGuid(testString, expectedString, isFinalBlock: true);
TryGetGuid_HasValueSequence_RetrievesGuid(testString, expectedString, isFinalBlock: false);
TryGetGuid_HasValueSequence_RetrievesGuid_Helper(testString, expectedString, isFinalBlock: true);
TryGetGuid_HasValueSequence_RetrievesGuid_Helper(testString, expectedString, isFinalBlock: false);
}

private static void TryGetGuid_HasValueSequence_RetrievesGuid(string testString, string expectedString, bool isFinalBlock)
private static void TryGetGuid_HasValueSequence_RetrievesGuid_Helper(string testString, string expectedString, bool isFinalBlock)
stephentoub marked this conversation as resolved.
Show resolved Hide resolved
{
byte[] dataUtf8 = Encoding.UTF8.GetBytes($"\"{testString}\"");
ReadOnlySequence<byte> sequence = JsonTestHelper.GetSequence(dataUtf8, 1);
Expand Down Expand Up @@ -1379,11 +1379,11 @@ public static void TestingStringsInvalidConversionToGuid(string testString)
[MemberData(nameof(JsonGuidTestData.InvalidGuidTests), MemberType = typeof(JsonGuidTestData))]
public static void TryGetGuid_HasValueSequence_False(string testString)
{
TryGetGuid_HasValueSequence_False(testString, isFinalBlock: true);
TryGetGuid_HasValueSequence_False(testString, isFinalBlock: false);
TryGetGuid_HasValueSequence_False_Helper(testString, isFinalBlock: true);
TryGetGuid_HasValueSequence_False_Helper(testString, isFinalBlock: false);
}

private static void TryGetGuid_HasValueSequence_False(string testString, bool isFinalBlock)
private static void TryGetGuid_HasValueSequence_False_Helper(string testString, bool isFinalBlock)
stephentoub marked this conversation as resolved.
Show resolved Hide resolved
{
byte[] dataUtf8 = Encoding.UTF8.GetBytes($"\"{testString}\"");
ReadOnlySequence<byte> sequence = JsonTestHelper.GetSequence(dataUtf8, 1);
Expand Down
8 changes: 4 additions & 4 deletions src/libraries/System.Text.Json/tests/Utf8JsonWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4159,7 +4159,7 @@ public void WriteStrings(bool formatted, bool skipValidation)
[InlineData(true, false, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>mess\nage", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Hello, \nWorld!")]
[InlineData(false, true, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>mess\nage", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Hello, \nWorld!")]
[InlineData(false, false, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>mess\nage", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Hello, \nWorld!")]
public void WriteHelloWorldEscaped(bool formatted, bool skipValidation, string key, string value)
public void WriteHelloWorldEscaped_AdditionalCases(bool formatted, bool skipValidation, string key, string value)
{
string expectedStr = GetEscapedExpectedString(prettyPrint: formatted, key, value, StringEscapeHandling.EscapeHtml);

Expand Down Expand Up @@ -4666,7 +4666,7 @@ public void Utf16SurrogatePairReplacement_ValidPropertyName_ValidValue(bool skip
public void OutputConsistentWithJsonEncodedText()
{
string jsonEncodedText = $"{{\"{JsonEncodedText.Encode("propertyName+1")}\":\"{JsonEncodedText.Encode("value+1")}\"}}";

var output = new ArrayBufferWriter<byte>(1024);

using (var writer = new Utf8JsonWriter(output))
Expand Down Expand Up @@ -4880,7 +4880,7 @@ public void WriteStartEndWithPropertyNameArray(bool formatted, bool skipValidati
[InlineData(true, false, 100)]
[InlineData(false, true, 100)]
[InlineData(false, false, 100)]
public void WriteStartEndWithPropertyNameArray(bool formatted, bool skipValidation, int keyLength)
public void WriteStartEndWithPropertyNameArrayDifferentKeyLengths(bool formatted, bool skipValidation, int keyLength)
{
var keyChars = new char[keyLength];
for (int i = 0; i < keyChars.Length; i++)
Expand Down Expand Up @@ -4969,7 +4969,7 @@ public void WriteStartEndWithPropertyNameObject(bool formatted, bool skipValidat
[InlineData(true, false, 100)]
[InlineData(false, true, 100)]
[InlineData(false, false, 100)]
public void WriteStartEndWithPropertyNameObject(bool formatted, bool skipValidation, int keyLength)
public void WriteStartEndWithPropertyNameObjectDifferentKeyLengths(bool formatted, bool skipValidation, int keyLength)
{
var keyChars = new char[keyLength];
for (int i = 0; i < keyChars.Length; i++)
Expand Down