Repository navigation
NUnit2022
Mikkel Nylander Bundgaard edited this page Apr 25, 2020
·
2 revisions
| Topic | Value |
|---|---|
| Id | NUnit2022 |
| Severity | Warning |
| Enabled | True |
| Category | Assertion |
| Code | MissingPropertyAnalyzer |
Provided 'actual' argument should have required property for constraint.
Using property constraints (e.g. Has.Count.EqualTo(1), Has.Property("Prop").EqualTo(expected), etc)
makes sense only when provided actual argument has those properties defined.
[Test]
public void Test()
{
var enumerable = new [] {1,2,3}.Where(i => i > 1);
// Actual argument type 'IEnumerable<int>' has no property 'Count'.
Assert.That(enumerable, Has.Count.EqualTo(2));
}Fix your property name, or use another constraint.
Configure the severity per project, for more info see MSDN.
#pragma warning disable NUnit2022 // Missing property required for constraint.
Code violating the rule here
#pragma warning restore NUnit2022 // Missing property required for constraint.Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit2022 // Missing property required for constraint.[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
"NUnit2022:Missing property required for constraint.",
Justification = "Reason...")]Copyright (c) 2018 The NUnit Project - Licensed under CC BY-NC-SA 4.0