Re-enable xunit warning 2017 (dotnet/corefx#40467)
authormadmir <1119735+madmir@users.noreply.github.com>
Thu, 22 Aug 2019 14:17:26 +0000 (16:17 +0200)
committerStephen Toub <stoub@microsoft.com>
Thu, 22 Aug 2019 14:17:26 +0000 (10:17 -0400)
* Re-enable xunit warning 2017

Use specialized assertions for checking for elements in collections.

* Revert Re-enable xunit warning 2017, revert some test changes

* Address PR feedback

Commit migrated from https://github.com/dotnet/corefx/commit/2fc48e13e87a4e68576d7df7af420ac2874e929e

28 files changed:
src/libraries/Microsoft.VisualBasic.Core/tests/Microsoft/VisualBasic/FileIO/FileSystemTests.cs
src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/Hosting/CompositionBatchTests.cs
src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/ImportingComposablePart.cs
src/libraries/System.ComponentModel.Composition/tests/System/Integration/DelayLoadingTests.cs
src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.netcoreapp.cs
src/libraries/System.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.RetrieveStatistics.cs
src/libraries/System.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs
src/libraries/System.Diagnostics.DiagnosticSource/tests/ActivityTests.cs
src/libraries/System.Diagnostics.DiagnosticSource/tests/HttpHandlerDiagnosticListenerTests.cs
src/libraries/System.Diagnostics.EventLog/tests/EventLogTests/EventLogTests.cs
src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs
src/libraries/System.DirectoryServices.AccountManagement/tests/AccountManagementTests.cs
src/libraries/System.DirectoryServices/tests/System/DirectoryServices/ActiveDirectory/ActiveDirectoryTests.cs
src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs
src/libraries/System.IO.FileSystem.AccessControl/tests/DirectoryObjectSecurityTests.cs
src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs
src/libraries/System.Linq.Expressions/tests/Block/NoParameterBlockTests.cs
src/libraries/System.Linq.Expressions/tests/Block/ParameterBlockTests.cs
src/libraries/System.Linq.Expressions/tests/Lambda/LambdaTests.cs
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNegotiatedCipherSuiteTest.cs
src/libraries/System.Private.Xml/tests/Misc/RandomizedHashing.cs
src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
src/libraries/System.Runtime.Serialization.Json/tests/DataContractJsonSerializer.cs
src/libraries/System.Runtime.Serialization.Xml/tests/DataContractSerializer.cs
src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs
src/libraries/System.Text.Json/tests/NewtonsoftTests/ImmutableCollectionsTests.cs
src/libraries/System.Threading.Tasks.Parallel/tests/RangePartitioner1Chunk.cs

index 1aed2fb..3e987d4 100644 (file)
@@ -409,7 +409,7 @@ namespace Microsoft.VisualBasic.FileIO.Tests
             Assert.Equal(6, DirectoryList.Count);
             for (int i = 0; i < 6; i++)
             {
-                Assert.True(DirectoryList.Contains(System.IO.Path.Combine(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory{i}")));
+                Assert.Contains(System.IO.Path.Combine(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory{i}"), DirectoryList);
             }
             System.IO.Directory.CreateDirectory(System.IO.Path.Combine(TestDirectory, $"GetDirectories_DirectoryNewSubDirectory0", $"NewSubSubDirectory"));
             DirectoryList = FileIO.FileSystem.GetDirectories(TestDirectory);
@@ -429,7 +429,7 @@ namespace Microsoft.VisualBasic.FileIO.Tests
             Assert.Equal(6, DirectoryList.Count);
             for (int i = 0; i < 6; i++)
             {
-                Assert.True(DirectoryList.Contains(System.IO.Path.Combine(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory{i}")));
+                Assert.Contains(System.IO.Path.Combine(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory{i}"), DirectoryList);
             }
             System.IO.Directory.CreateDirectory(System.IO.Path.Combine(TestDirectory, $"GetDirectories_Directory_SearchOptionNewSubDirectory0", $"NewSubSubDirectory"));
             DirectoryList = FileIO.FileSystem.GetDirectories(TestDirectory, SearchOption.SearchTopLevelOnly);
@@ -526,7 +526,7 @@ namespace Microsoft.VisualBasic.FileIO.Tests
             Assert.Equal(6, FileList.Count);
             for (int i = 0; i < 6; i++)
             {
-                Assert.True(FileList.Contains(System.IO.Path.Combine(TestDirectory, $"NewFile{i}")));
+                Assert.Contains(System.IO.Path.Combine(TestDirectory, $"NewFile{i}"), FileList);
             }
             System.IO.Directory.CreateDirectory(System.IO.Path.Combine(TestDirectory, "GetFiles_DirectoryNewSubDirectory"));
             CreateTestFile(SourceData, PathFromBase: "GetFiles_DirectoryNewSubDirectory", TestFileName: "NewFile");
@@ -551,7 +551,7 @@ namespace Microsoft.VisualBasic.FileIO.Tests
             Assert.Equal(6, FileList.Count);
             for (int i = 0; i < 6; i++)
             {
-                Assert.True(FileList.Contains(System.IO.Path.Combine(TestDirectory, $"NewFile{i}")));
+                Assert.Contains(System.IO.Path.Combine(TestDirectory, $"NewFile{i}"), FileList);
             }
             FileList = FileIO.FileSystem.GetFiles(TestDirectory, SearchOption.SearchAllSubDirectories);
             Assert.Equal(8, FileList.Count);
@@ -575,7 +575,7 @@ namespace Microsoft.VisualBasic.FileIO.Tests
             Assert.Equal(3, FileList.Count);
             for (int i = 0; i < 3; i++)
             {
-                Assert.True(TestFileList.Contains(FileList[i]));
+                Assert.Contains(FileList[i], TestFileList);
             }
             var NewSubDirectoryPath = System.IO.Path.Combine(TestDirectory, "GetFiles_Directory_SearchOption_WildcardsNewSubDirectory");
             System.IO.Directory.CreateDirectory(NewSubDirectoryPath);
index 5e2536e..705051f 100644 (file)
@@ -146,13 +146,13 @@ namespace System.ComponentModel.Composition
             ComposablePart part2 = PartFactory.Create();
 
             batch.AddPart(part1);
-            Assert.True(batch.PartsToAdd.Contains(part1));
+            Assert.Contains(part1, batch.PartsToAdd);
 
             ReadOnlyCollection<ComposablePart> partsToAddBeforeCopy = batch.PartsToAdd;
             Assert.Same(partsToAddBeforeCopy, batch.PartsToAdd);
 
             Assert.Equal(1, partsToAddBeforeCopy.Count);
-            Assert.True(partsToAddBeforeCopy.Contains(part1));
+            Assert.Contains(part1, partsToAddBeforeCopy);
 
             batch.AddPart(part2);
 
@@ -160,8 +160,8 @@ namespace System.ComponentModel.Composition
             Assert.Same(partsToAddAfterCopy, batch.PartsToAdd);
 
             Assert.Equal(2, partsToAddAfterCopy.Count);
-            Assert.True(partsToAddAfterCopy.Contains(part1));
-            Assert.True(partsToAddAfterCopy.Contains(part2));
+            Assert.Contains(part1, partsToAddAfterCopy);
+            Assert.Contains(part2, partsToAddAfterCopy);
             Assert.NotSame(partsToAddBeforeCopy, partsToAddAfterCopy);
         }
 
@@ -173,13 +173,13 @@ namespace System.ComponentModel.Composition
             ComposablePart part2 = PartFactory.Create();
 
             batch.RemovePart(part1);
-            Assert.True(batch.PartsToRemove.Contains(part1));
+            Assert.Contains(part1, batch.PartsToRemove);
 
             ReadOnlyCollection<ComposablePart> partsToRemoveBeforeCopy = batch.PartsToRemove;
             Assert.Same(partsToRemoveBeforeCopy, batch.PartsToRemove);
 
             Assert.Equal(1, partsToRemoveBeforeCopy.Count);
-            Assert.True(partsToRemoveBeforeCopy.Contains(part1));
+            Assert.Contains(part1, partsToRemoveBeforeCopy);
 
             batch.RemovePart(part2);
 
@@ -187,8 +187,8 @@ namespace System.ComponentModel.Composition
             Assert.Same(partsToRemoveAfterCopy, batch.PartsToRemove);
 
             Assert.Equal(2, partsToRemoveAfterCopy.Count);
-            Assert.True(partsToRemoveAfterCopy.Contains(part1));
-            Assert.True(partsToRemoveAfterCopy.Contains(part2));
+            Assert.Contains(part1, partsToRemoveAfterCopy);
+            Assert.Contains(part2, partsToRemoveAfterCopy);
             Assert.NotSame(partsToRemoveBeforeCopy, partsToRemoveAfterCopy);
         }
 
@@ -320,7 +320,7 @@ namespace System.ComponentModel.Composition
             Assert.Equal(1, batch.PartsToAdd.Count);
 
             Assert.Equal("Value", this.GetSingleExport(batch.PartsToAdd[0], "Contract").Value);
-            Assert.True(batch.PartsToAdd.Contains(part));
+            Assert.Contains(part, batch.PartsToAdd);
         }
 
         [Fact]
@@ -332,7 +332,7 @@ namespace System.ComponentModel.Composition
             Assert.Equal(1, batch.PartsToAdd.Count);
 
             Assert.Equal("Value", this.GetSingleLazy<string>(batch.PartsToAdd[0]).Value);
-            Assert.True(batch.PartsToAdd.Contains(part));
+            Assert.Contains(part, batch.PartsToAdd);
         }
 
         [Fact]
@@ -344,7 +344,7 @@ namespace System.ComponentModel.Composition
             Assert.Equal(1, batch.PartsToAdd.Count);
 
             Assert.Equal("Value", this.GetSingleExport(batch.PartsToAdd[0], "Contract").Value);
-            Assert.True(batch.PartsToAdd.Contains(part));
+            Assert.Contains(part, batch.PartsToAdd);
         }
 
         [Fact]
index 382aa67..00b3252 100644 (file)
@@ -109,7 +109,7 @@ namespace System.ComponentModel.Composition
 
         public override void SetImport(ImportDefinition definition, IEnumerable<Export> exports)
         {
-            Assert.True(_importDefinitions.Contains(definition));
+            Assert.Contains(definition, _importDefinitions);
 
             ImportSatisfiedCount++;
 
@@ -118,7 +118,7 @@ namespace System.ComponentModel.Composition
 
         public void ResetImport(ImportDefinition definition)
         {
-            Assert.True(_importDefinitions.Contains(definition));
+            Assert.Contains(definition, _importDefinitions);
             _importValues[definition] = null;
         }
 
index 80482af..3bc754a 100644 (file)
@@ -287,12 +287,12 @@ namespace Tests.Integration
 
             public void AssertLoaded(Type type)
             {
-                Assert.True(this.LoadedTypes.Contains(type));
+                Assert.Contains(type, this.LoadedTypes);
             }
 
             public void AssertNotLoaded(Type type)
             {
-                Assert.False(this.LoadedTypes.Contains(type));
+                Assert.DoesNotContain(type, this.LoadedTypes);
             }
 
         }
index 122654e..d4521e5 100644 (file)
@@ -173,8 +173,8 @@ namespace System.Data.Common
             Assert.Equal(2, providerTable.Rows.Count);
             List<string> invariantNames = DbProviderFactories.GetProviderInvariantNames().ToList();
             Assert.Equal(2, invariantNames.Count);
-            Assert.True(invariantNames.Contains("System.Data.Common.TestProvider"));
-            Assert.True(invariantNames.Contains("System.Data.SqlClient"));
+            Assert.Contains("System.Data.Common.TestProvider", invariantNames);
+            Assert.Contains("System.Data.SqlClient", invariantNames);
         }
 
         private void ClearRegisteredFactories()
index 97b0120..fef9f9e 100644 (file)
@@ -307,7 +307,7 @@ namespace System.Data.SqlClient.Tests
                     Assert.Same(e.Key, e.Entry.Key);
                     Assert.Same(e.Value, e.Entry.Value);
 
-                    Assert.True(s_retrieveStatisticsKeys.Contains(e.Entry.Key));
+                    Assert.Contains(e.Entry.Key, s_retrieveStatisticsKeys);
                 }
 
                 Assert.False(e.MoveNext());
@@ -352,7 +352,7 @@ namespace System.Data.SqlClient.Tests
                     Assert.NotNull(entry.Value);
                     Assert.IsType<long>(entry.Value);
 
-                    Assert.True(s_retrieveStatisticsKeys.Contains(entry.Key));
+                    Assert.Contains(entry.Key, s_retrieveStatisticsKeys);
                 }
 
                 Assert.False(e.MoveNext());
@@ -461,7 +461,7 @@ namespace System.Data.SqlClient.Tests
                 {
                     Assert.True(e.MoveNext());
                     Assert.NotNull(e.Current);
-                    Assert.True(s_retrieveStatisticsKeys.Contains(e.Current));
+                    Assert.Contains(e.Current, s_retrieveStatisticsKeys);
                 }
 
                 Assert.False(e.MoveNext());
index e1d0e0a..478f225 100644 (file)
@@ -57,8 +57,8 @@ namespace System.Data.SqlClient.ManualTesting.Tests
 
                         } while (reader.NextResult());
 
-                        Assert.True(columnNames.Contains("ColInteger"));
-                        Assert.True(columnNames.Contains("ColString"));
+                        Assert.Contains("ColInteger", columnNames);
+                        Assert.Contains("ColString", columnNames);
                     }
                 }
             }
@@ -148,4 +148,4 @@ namespace System.Data.SqlClient.ManualTesting.Tests
             return columnSetPresent;
         }
     }
-}
\ No newline at end of file
+}
index 20cb574..8a4a8ae 100644 (file)
@@ -211,7 +211,7 @@ namespace System.Diagnostics.Tests
 
             // With probability 1/MaxLong, Activity.Id length may be expectedIdLength + 1
             Assert.InRange(activity.Id.Length, expectedIdLength, expectedIdLength + 1);
-            Assert.False(activity.Id.Contains('#'));
+            Assert.DoesNotContain('#', activity.Id);
         }
 
         /// <summary>
index 8abf064..9ba9e49 100644 (file)
@@ -445,9 +445,9 @@ namespace System.Diagnostics.Tests
                 string[] correlationContext = thisRequest.Headers["Correlation-Context"].Split(',');
 
                 Assert.Equal(3, correlationContext.Length);
-                Assert.True(correlationContext.Contains("key=value"));
-                Assert.True(correlationContext.Contains("bad%2Fkey=value"));
-                Assert.True(correlationContext.Contains("goodkey=bad%2Fvalue"));
+                Assert.Contains("key=value", correlationContext);
+                Assert.Contains("bad%2Fkey=value", correlationContext);
+                Assert.Contains("goodkey=bad%2Fvalue", correlationContext);
             }
             parentActivity.Stop();
         }
index e4b0f40..6614b88 100644 (file)
@@ -366,7 +366,7 @@ namespace System.Diagnostics.Tests
         public void GetEventLogContainsSecurityLogTest()
         {
             EventLog[] eventlogs = EventLog.GetEventLogs();
-            Assert.True(eventlogs.Select(t => t.Log).Contains("Security", StringComparer.OrdinalIgnoreCase));
+            Assert.Contains("Security", eventlogs.Select(t => t.Log), StringComparer.OrdinalIgnoreCase);
         }
     }
 }
index ae77b8e..0113b2b 100644 (file)
@@ -28,7 +28,7 @@ namespace BasicEventSourceTests
                 using (var el = new LoudListener(log))
                 {
                     var sources = EventSource.GetSources();
-                    Assert.True(sources.Contains(log));
+                    Assert.Contains(log, sources);
 
                     Assert.NotNull(EventSource.GenerateManifest(typeof(SimpleEventSource), string.Empty, EventManifestOptions.OnlyIfNeededForRegistration));
                     Assert.Null(EventSource.GenerateManifest(typeof(EventSourceTest), string.Empty, EventManifestOptions.OnlyIfNeededForRegistration));
index 5204c19..376db86 100644 (file)
@@ -160,7 +160,7 @@ namespace System.DirectoryServices.AccountManagement.Tests
 
                     // First, check the user is not in the group
 
-                    Assert.False(user.GetGroups().Contains(group));
+                    Assert.DoesNotContain(group, user.GetGroups());
                     Assert.False(user.IsMemberOf(group));
                     Assert.False(group.Members.Contains(user));
 
@@ -169,14 +169,14 @@ namespace System.DirectoryServices.AccountManagement.Tests
                     group.Members.Add(context, IdentityType.Name, user.Name);
                     group.Save();
 
-                    Assert.True(user.GetGroups().Contains(group));
+                    Assert.Contains(group, user.GetGroups());
                     Assert.True(user.IsMemberOf(group));
                     Assert.True(group.Members.Contains(user));
 
                     // Third, remove the user from the group and check again
                     group.Members.Remove(context, IdentityType.Name, user.Name);
                     group.Save();
-                    Assert.False(user.GetGroups().Contains(group));
+                    Assert.DoesNotContain(group, user.GetGroups());
                     Assert.False(user.IsMemberOf(group));
                     Assert.False(group.Members.Contains(user));
                 }
index 922b051..8ba0601 100644 (file)
@@ -401,7 +401,7 @@ namespace System.DirectoryServices.Tests
 
                         partitions = new string[ds.Partitions.Count];
                         ds.Partitions.CopyTo(partitions, 0);
-                        Assert.True(partitions.Contains(firstPartition));
+                        Assert.Contains(firstPartition, partitions);
                     }
                 }
             }
index b067999..ef7e945 100644 (file)
@@ -124,7 +124,7 @@ namespace System.Globalization.Tests
         public void CurrencySymbol(string name, string[] expected)
         {
             string result = new RegionInfo(name).CurrencySymbol;
-            Assert.True(expected.Contains(result));
+            Assert.Contains(result, expected);
         }
 
         [Theory]
index c8d8924..d95aedd 100644 (file)
@@ -183,7 +183,7 @@ namespace System.Security.AccessControl
                .GetAuditRules(true, true, typeof(System.Security.Principal.NTAccount));
 
             List<CustomAuditRule> existingRules = ruleCollection.Cast<CustomAuditRule>().ToList();
-            Assert.False(existingRules.Contains(customAuditRuleReadWrite));
+            Assert.DoesNotContain(customAuditRuleReadWrite, existingRules);
         }
 
 
@@ -415,7 +415,7 @@ namespace System.Security.AccessControl
                .GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
 
             List<CustomAccessRule> existingRules = ruleCollection.Cast<CustomAccessRule>().ToList();
-            Assert.False(existingRules.Contains(customAccessRuleReadWrite));
+            Assert.DoesNotContain(customAccessRuleReadWrite, existingRules);
         }
 
         [Fact]
@@ -475,8 +475,8 @@ namespace System.Security.AccessControl
 
             List<CustomAccessRule> existingRules = ruleCollection.Cast<CustomAccessRule>().ToList();
 
-            Assert.False(existingRules.Contains(customAccessRuleReadWrite));
-            Assert.False(existingRules.Contains(customAccessRuleSynchronize));
+            Assert.DoesNotContain(customAccessRuleReadWrite, existingRules);
+            Assert.DoesNotContain(customAccessRuleSynchronize, existingRules);
         }
 
         [Fact]
@@ -521,8 +521,8 @@ namespace System.Security.AccessControl
                .GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
 
             List<CustomAccessRule> existingRules = ruleCollection.Cast<CustomAccessRule>().ToList();
-            Assert.False(existingRules.Contains(customAccessRuleReadWrite));
-            Assert.False(existingRules.Contains(customAccessRuleSynchronize));
+            Assert.DoesNotContain(customAccessRuleReadWrite, existingRules);
+            Assert.DoesNotContain(customAccessRuleSynchronize, existingRules);
         }
 
 
index 6481617..0e9b25c 100644 (file)
@@ -775,8 +775,8 @@ namespace System.IO.Tests
             watcher.Filters.Add("*.dll");
             watcher.Filters.Add(string.Empty);
 
-            Assert.False(watcher.Filters.Contains(string.Empty));
-            Assert.True(watcher.Filters.Contains("*"));
+            Assert.DoesNotContain(string.Empty, watcher.Filters);
+            Assert.Contains("*", watcher.Filters);
         }
 
         [Fact]
@@ -787,8 +787,8 @@ namespace System.IO.Tests
             watcher.Filters.Add("*.dll");
             watcher.Filters.Add(null);
 
-            Assert.False(watcher.Filters.Contains(null));
-            Assert.True(watcher.Filters.Contains("*"));
+            Assert.DoesNotContain(null, watcher.Filters);
+            Assert.Contains("*", watcher.Filters);
         }
 
         [Fact]
@@ -798,7 +798,7 @@ namespace System.IO.Tests
             watcher.Filters.Add("*.pdb");
             watcher.Filters.Add("*.dll");
 
-            Assert.True(watcher.Filters.Contains("*.pdb"));
+            Assert.Contains("*.pdb", watcher.Filters);
         }
 
         [Fact]
index 6f59c3d..63486f9 100644 (file)
@@ -364,7 +364,7 @@ namespace System.Linq.Expressions.Tests
                     Assert.Same(exps[i], en.Current);
                     Assert.Same(exps[i], nonGenEn.Current);
                     Assert.Equal(i, children.IndexOf(exps[i]));
-                    Assert.True(children.Contains(exps[i]));
+                    Assert.Contains(exps[i], children);
                 }
 
                 Assert.False(en.MoveNext());
@@ -383,7 +383,7 @@ namespace System.Linq.Expressions.Tests
             AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => children[-1]);
             AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => children[parCount]);
             Assert.Equal(-1, children.IndexOf(Expression.Parameter(typeof(int))));
-            Assert.False(children.Contains(Expression.Parameter(typeof(int))));
+            Assert.DoesNotContain(Expression.Parameter(typeof(int)), children);
         }
 
         [Theory]
@@ -396,7 +396,7 @@ namespace System.Linq.Expressions.Tests
             BlockExpression block = Expression.Block(expressions);
 
             Assert.Equal(-1, block.Expressions.IndexOf(Expression.Default(typeof(long))));
-            Assert.False(block.Expressions.Contains(null));
+            Assert.DoesNotContain(null, block.Expressions);
         }
 
         [Theory]
index cadcf42..d9e500b 100644 (file)
@@ -226,7 +226,7 @@ namespace System.Linq.Expressions.Tests
             BlockExpression block = Expression.Block(SingleParameter, expressions);
 
             Assert.Equal(-1, block.Expressions.IndexOf(Expression.Default(typeof(long))));
-            Assert.False(block.Expressions.Contains(null));
+            Assert.DoesNotContain(null, block.Expressions);
         }
 
         [Theory]
index e9e5868..28c64fc 100644 (file)
@@ -757,7 +757,7 @@ namespace System.Linq.Expressions.Tests
                     Assert.Same(pars[i], en.Current);
                     Assert.Same(pars[i], nonGenEn.Current);
                     Assert.Equal(i, parameters.IndexOf(pars[i]));
-                    Assert.True(parameters.Contains(pars[i]));
+                    Assert.Contains(pars[i], parameters);
                 }
 
                 Assert.False(en.MoveNext());
@@ -776,7 +776,7 @@ namespace System.Linq.Expressions.Tests
             AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => parameters[-1]);
             AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => parameters[parCount]);
             Assert.Equal(-1, parameters.IndexOf(Expression.Parameter(typeof(int))));
-            Assert.False(parameters.Contains(Expression.Parameter(typeof(int))));
+            Assert.DoesNotContain(Expression.Parameter(typeof(int)), parameters);
         }
 
         [Theory, ClassData(typeof(CompilationTypes))]
index 8162da8..1ea0ed1 100644 (file)
@@ -525,9 +525,9 @@ namespace System.Net.Http.Functional.Tests
                         Assert.True(request.Headers.TryGetValues("Request-Id", out var requestId));
                         Assert.True(request.Headers.TryGetValues("Correlation-Context", out var correlationContext));
                         Assert.Equal(3, correlationContext.Count());
-                        Assert.True(correlationContext.Contains("key=value"));
-                        Assert.True(correlationContext.Contains("bad%2Fkey=value"));
-                        Assert.True(correlationContext.Contains("goodkey=bad%2Fvalue"));
+                        Assert.Contains("key=value", correlationContext);
+                        Assert.Contains("bad%2Fkey=value", correlationContext);
+                        Assert.Contains("goodkey=bad%2Fvalue", correlationContext);
 
                         var requestStatus = GetPropertyValueFromAnonymousTypeInstance<TaskStatus>(kvp.Value, "RequestTaskStatus");
                         Assert.Equal(TaskStatus.RanToCompletion, requestStatus);
index 3d94a6d..b12ad9b 100644 (file)
@@ -398,7 +398,7 @@ namespace System.Net.Security.Tests
 
                 foreach (var cs in csp.AllowedCipherSuites)
                 {
-                    Assert.True(cipherSuites.Contains(cs));
+                    Assert.Contains(cs, cipherSuites);
                 }
             }
         }
index 4a2e10e..ed1dcda 100644 (file)
@@ -50,7 +50,7 @@ namespace System.Xml.Tests
         public void StringsDontHashToAnyKnownNonRandomizedSets()
         {
             var setOfHashes = new Tuple<int, int, int>(_strings[0].GetHashCode(), _strings[1].GetHashCode(), _strings[2].GetHashCode());
-            Assert.False(_knownNonRandomizedHashesOfStrings.Contains(setOfHashes));
+            Assert.DoesNotContain(setOfHashes, _knownNonRandomizedHashesOfStrings);
         }
 
         [Fact]
index d38b596..165b115 100644 (file)
@@ -351,7 +351,7 @@ public static partial class XmlSerializerTests
         Assert.True(y.Count == 2);
         foreach (string item in x)
         {
-            Assert.True(y.Contains(item));
+            Assert.Contains(item, y);
         }
     }
 
@@ -731,7 +731,7 @@ public static partial class XmlSerializerTests
 
         foreach (var item in value)
         {
-            Assert.True(actual.Contains(item));
+            Assert.Contains(item, actual);
         }
     }
 
index 026796a..0f7566b 100644 (file)
@@ -682,7 +682,7 @@ public static partial class DataContractJsonSerializerTests
 
         foreach (var item in x)
         {
-            Assert.True(y.Contains(item));
+            Assert.Contains(item, y);
         }
     }
 
index cf4eb94..ae758d2 100644 (file)
@@ -559,7 +559,7 @@ public static partial class DataContractSerializerTests
         Assert.True(y.Count == 2);
         foreach (var item in x)
         {
-            Assert.True(y.Contains(item));
+            Assert.Contains(item, y);
         }
     }
 
@@ -1227,9 +1227,9 @@ public static partial class DataContractSerializerTests
         var actual = DataContractSerializerHelper.SerializeAndDeserialize<SimpleCDC>(value, @"<SimpleCDC xmlns=""http://schemas.datacontract.org/2004/07/SerializationTypes"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><Item>One</Item><Item>Two</Item><Item>Three</Item></SimpleCDC>");
 
         Assert.True(actual.Count == 3);
-        Assert.True(actual.Contains("One"));
-        Assert.True(actual.Contains("Two"));
-        Assert.True(actual.Contains("Three"));
+        Assert.Contains("One", actual);
+        Assert.Contains("Two", actual);
+        Assert.Contains("Three", actual);
     }
 
     [Fact]
index dd304c3..d65c6d8 100644 (file)
@@ -304,7 +304,7 @@ namespace System.Security.Cryptography.Pkcs.Tests
 
                 foreach (X509Certificate2 documentCert in cms.Certificates)
                 {
-                    Assert.True(expectedCerts.Contains(documentCert));
+                    Assert.Contains(documentCert, expectedCerts);
                 }
             }
         }
index c2962d4..10e588a 100644 (file)
@@ -257,9 +257,9 @@ namespace System.Text.Json.Tests
 
             ImmutableHashSet<string> a = JsonSerializer.Deserialize<ImmutableHashSet<string>>(json);
             Assert.Equal(3, a.Count);
-            Assert.True(a.Contains("One"));
-            Assert.True(a.Contains("II"));
-            Assert.True(a.Contains("3"));
+            Assert.Contains("One", a);
+            Assert.Contains("II", a);
+            Assert.Contains("3", a);
         }
 
         [Fact]
@@ -274,9 +274,9 @@ namespace System.Text.Json.Tests
             ImmutableHashSet<string> data = JsonSerializer.Deserialize<ImmutableHashSet<string>>(json);
 
             Assert.Equal(3, data.Count);
-            Assert.True(data.Contains("3"));
-            Assert.True(data.Contains("II"));
-            Assert.True(data.Contains("One"));
+            Assert.Contains("3", data);
+            Assert.Contains("II", data);
+            Assert.Contains("One", data);
         }
 
         [Fact]
@@ -324,9 +324,9 @@ namespace System.Text.Json.Tests
             ImmutableSortedSet<string> data = JsonSerializer.Deserialize<ImmutableSortedSet<string>>(json);
 
             Assert.Equal(3, data.Count);
-            Assert.True(data.Contains("3"));
-            Assert.True(data.Contains("II"));
-            Assert.True(data.Contains("One"));
+            Assert.Contains("3", data);
+            Assert.Contains("II", data);
+            Assert.Contains("One", data);
         }
         #endregion
 
index ce82df2..ade05f4 100644 (file)
@@ -272,7 +272,7 @@ namespace System.Threading.Tasks.Tests
         /// <param name="userException"></param>
         private static void VerifyAggregateException(AggregateException aggregatEx, Exception userException)
         {
-            Assert.True(aggregatEx.InnerExceptions.Contains(userException));
+            Assert.Contains(userException, aggregatEx.InnerExceptions);
             Assert.Equal(1, aggregatEx.Flatten().InnerExceptions.Count);
         }