MSTEST0023: Do not negate boolean assertions
Property | Value |
---|---|
Rule ID | MSTEST0023 |
Title | Do not negate boolean assertions |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default | Yes |
Default severity | Info |
Introduced in version | 3.4.0 |
Cause
This rule raises a diagnostic when a call to Assert.IsTrue
or Assert.IsFalse
contains a negated argument.
Rule description
MSTest assertion library contains opposite APIs that makes it easier to test true
and false
cases. It is recommend to use the right API for the right case as it is improving readability and also provides better information in case of failure.
How to fix violations
When negating argument in a Assert.IsTrue
call, you should use Assert.IsFalse
.
When negating argument in a Assert.IsFalse
call, you should use Assert.IsTrue
.
When to suppress warnings
Do not suppress warnings from this rule.
التعاون معنا على GitHub
يمكن العثور على مصدر هذا المحتوى على GitHub حيث يمكنك أيضاً إضافة مشاكل وطلبات سحب ومراجعتها. للحصول على معلومات إضافية، اطلع على دليل المساهم لدينا.
الملاحظات
https://aka.ms/ContentUserFeedback.
قريبًا: خلال عام 2024، سنتخلص تدريجيًا من GitHub Issues بوصفها آلية إرسال ملاحظات للمحتوى ونستبدلها بنظام ملاحظات جديد. لمزيد من المعلومات، راجعإرسال الملاحظات وعرضها المتعلقة بـ