<Rule Id="xUnit2005" Action="None" /> <!-- Do not use identity check on value type -->
<Rule Id="xUnit2006" Action="None" /> <!-- Do not use invalid string equality check -->
<Rule Id="xUnit2007" Action="None" /> <!-- Do not use typeof expression to check the type -->
- <Rule Id="xUnit2008" Action="None" /> <!-- Do not use boolean check to match on regular expressions -->
<Rule Id="xUnit2009" Action="None" /> <!-- Do not use boolean check to check for substrings -->
<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 -->
{
var item = new ImportDefinition(e.Input, "", ImportCardinality.ExactlyOne, false, false);
- Assert.True(Regex.IsMatch(item.ToString(), e.Output));
+ Assert.Matches(e.Output, item.ToString());
}
}
{
var item = new DerivedImportDefinition(e.Input);
- Assert.True(Regex.IsMatch(item.ToString(), e.Output));
+ Assert.Matches(e.Output, item.ToString());
}
}
var traceparent = startRequest.Headers["traceparent"];
Assert.NotNull(traceparent);
- Assert.True(Regex.IsMatch(traceparent, "^[0-9a-f][0-9a-f]-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f][0-9a-f]$"));
+ Assert.Matches("^[0-9a-f][0-9a-f]-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f][0-9a-f]$", traceparent);
Assert.Null(startRequest.Headers["tracestate"]);
Assert.Null(startRequest.Headers["Request-Id"]);
}
Assert.Equal("some=state", tracestate);
Assert.Equal("k=v", correlationContext);
Assert.True(traceparent.StartsWith($"00-{parent.TraceId.ToHexString()}-"));
- Assert.True(Regex.IsMatch(traceparent, "^[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$"));
+ Assert.Matches("^[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$", traceparent);
Assert.Null(startRequest.Headers["Request-Id"]);
}
}
string message = _event.PayloadString(0, "message");
// expected message: "ERROR: Exception in Command Processing for EventSource BadEventSource_Bad_Type_ByteArray: Unsupported type Byte[] in event source. "
- Assert.True(Regex.IsMatch(message, "Unsupported type"));
+ Assert.Matches("Unsupported type", message);
}
}
finally
Debug.WriteLine(string.Format("Message=\"{0}\"", message));
// expected message: "ERROR: Exception in Command Processing for EventSource BadEventSource_MismatchedIds: Event Event2 was assigned event ID 2 but 1 was passed to WriteEvent. "
if (!PlatformDetection.IsFullFramework) // Full framework has typo
- Assert.True(Regex.IsMatch(message, "Event Event2 was assigned event ID 2 but 1 was passed to WriteEvent"));
+ Assert.Matches("Event Event2 was assigned event ID 2 but 1 was passed to WriteEvent", message);
}
[Fact]
Assert.Equal(logger.Name, evts[0].ProviderName);
Assert.Equal("EventSourceMessage", evts[0].EventName);
string errorMsg = evts[0].PayloadString(0, "message");
- Assert.True(Regex.IsMatch(errorMsg, "called with 1.*defined with 3"));
+ Assert.Matches("called with 1.*defined with 3", errorMsg);
}
int eventIdx = evts.Count - 1;
Assert.Equal(format.Guid, codecInfo.FormatID);
Assert.Contains(CodecName, codecInfo.CodecName);
Assert.Equal(DllName, codecInfo.DllName);
- Assert.True(extRegex.IsMatch(codecInfo.FilenameExtension));
+ Assert.Matches(extRegex, codecInfo.FilenameExtension);
Assert.Equal(Flags, codecInfo.Flags);
Assert.Contains(FormatDescription, codecInfo.FormatDescription);
Assert.Contains(MimeType, codecInfo.MimeType);
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
- Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("]]>") + @"[\p{Pf}\p{Po}]"));
- Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
- Assert.True(Regex.IsMatch(exception.Message, @"\b" + "CDATA" + @"\b"));
+ Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape("]]>") + @"[\p{Pf}\p{Po}]", exception.Message);
+ Assert.Matches(@"\b" + "XML" + @"\b", exception.Message);
+ Assert.Matches(@"\b" + "CDATA" + @"\b", exception.Message);
}
}
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
- Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
- Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("--") + @"[\p{Pf}\p{Po}]"));
- Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("-") + @"[\p{Pf}\p{Po}]"));
+ Assert.Matches(@"\b" + "XML" + @"\b", exception.Message);
+ Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape("--") + @"[\p{Pf}\p{Po}]", exception.Message);
+ Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape("-") + @"[\p{Pf}\p{Po}]", exception.Message);
}
}
}
// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
- Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("?>") + @"[\p{Pf}\p{Po}]"));
- Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
+ Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape("?>") + @"[\p{Pf}\p{Po}]", exception.Message);
+ Assert.Matches(@"\b" + "XML" + @"\b", exception.Message);
}
}
<PropertyGroup>
<ProjectGuid>{94B106C2-D574-4392-80AB-3EE308A078DF}</ProjectGuid>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
+ <NoWarn>$(NoWarn);xUnit2008</NoWarn>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release</Configurations>
</PropertyGroup>
<PropertyGroup>