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);
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);
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");
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);
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);
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);
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);
}
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);
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);
}
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]
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]
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]
public override void SetImport(ImportDefinition definition, IEnumerable<Export> exports)
{
- Assert.True(_importDefinitions.Contains(definition));
+ Assert.Contains(definition, _importDefinitions);
ImportSatisfiedCount++;
public void ResetImport(ImportDefinition definition)
{
- Assert.True(_importDefinitions.Contains(definition));
+ Assert.Contains(definition, _importDefinitions);
_importValues[definition] = null;
}
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);
}
}
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()
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());
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());
{
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());
} while (reader.NextResult());
- Assert.True(columnNames.Contains("ColInteger"));
- Assert.True(columnNames.Contains("ColString"));
+ Assert.Contains("ColInteger", columnNames);
+ Assert.Contains("ColString", columnNames);
}
}
}
return columnSetPresent;
}
}
-}
\ No newline at end of file
+}
// 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>
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();
}
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);
}
}
}
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));
// 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));
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));
}
partitions = new string[ds.Partitions.Count];
ds.Partitions.CopyTo(partitions, 0);
- Assert.True(partitions.Contains(firstPartition));
+ Assert.Contains(firstPartition, partitions);
}
}
}
public void CurrencySymbol(string name, string[] expected)
{
string result = new RegionInfo(name).CurrencySymbol;
- Assert.True(expected.Contains(result));
+ Assert.Contains(result, expected);
}
[Theory]
.GetAuditRules(true, true, typeof(System.Security.Principal.NTAccount));
List<CustomAuditRule> existingRules = ruleCollection.Cast<CustomAuditRule>().ToList();
- Assert.False(existingRules.Contains(customAuditRuleReadWrite));
+ Assert.DoesNotContain(customAuditRuleReadWrite, existingRules);
}
.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]
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]
.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);
}
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]
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]
watcher.Filters.Add("*.pdb");
watcher.Filters.Add("*.dll");
- Assert.True(watcher.Filters.Contains("*.pdb"));
+ Assert.Contains("*.pdb", watcher.Filters);
}
[Fact]
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());
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]
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]
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]
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());
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))]
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);
foreach (var cs in csp.AllowedCipherSuites)
{
- Assert.True(cipherSuites.Contains(cs));
+ Assert.Contains(cs, cipherSuites);
}
}
}
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]
Assert.True(y.Count == 2);
foreach (string item in x)
{
- Assert.True(y.Contains(item));
+ Assert.Contains(item, y);
}
}
foreach (var item in value)
{
- Assert.True(actual.Contains(item));
+ Assert.Contains(item, actual);
}
}
foreach (var item in x)
{
- Assert.True(y.Contains(item));
+ Assert.Contains(item, y);
}
}
Assert.True(y.Count == 2);
foreach (var item in x)
{
- Assert.True(y.Contains(item));
+ Assert.Contains(item, y);
}
}
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]
foreach (X509Certificate2 documentCert in cms.Certificates)
{
- Assert.True(expectedCerts.Contains(documentCert));
+ Assert.Contains(documentCert, expectedCerts);
}
}
}
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]
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]
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
/// <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);
}