We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDictionary<TKey, TValue> implements ICollection<KeyValuePair<TKey, TValue>> and therefore has a Count property.
IDictionary<TKey, TValue>
ICollection<KeyValuePair<TKey, TValue>>
Count
The code in the screenshot can be found here:
https://github.com/SteamDatabase/ValveKeyValue/blob/a4cef9a8aacdfb92491314176216bf11a4b4cfc0/ValveKeyValue/ValveKeyValue.Test/Text/StronglyTypedCollectionDeserializationTestCase.cs#L24-L43
The text was updated successfully, but these errors were encountered:
Is it only the analyser? If you suppress NUnit2022 does the actual NUnit engine run fine?
Sorry, something went wrong.
Yep, the test passes.
The issue seems to be with the generic parameter constraint.
This does not raise NUnit2022:
[Test] public void TestCollectionMethod() { IDictionary<int, int> actual = new Dictionary<int, int>() { [1] = 1, [2] = 2 }; AssertCollectionCount(actual); AssertCollectionCount(actual.Values); AssertCollectionCount(actual.Keys); static void AssertCollectionCount<T>(ICollection<T> instance) { Assert.That(instance, Has.Count.EqualTo(2)); } }
But this version does:
[Test] public void TestGenericMethod() { IDictionary<int, int> actual = new Dictionary<int, int>() { [1] = 1, [2] = 2 }; AssertCollectionOfIntCount(actual.Values); AssertCollectionOfIntCount(actual.Keys); static void AssertCollectionOfIntCount<T>(T instance) where T : ICollection<int> { Assert.That(instance, Has.Count.EqualTo(2)); } }
So it seems we are not checking constraints.
manfred-brands
Successfully merging a pull request may close this issue.
IDictionary<TKey, TValue>
implementsICollection<KeyValuePair<TKey, TValue>>
and therefore has aCount
property.The code in the screenshot can be found here:
https://github.com/SteamDatabase/ValveKeyValue/blob/a4cef9a8aacdfb92491314176216bf11a4b4cfc0/ValveKeyValue/ValveKeyValue.Test/Text/StronglyTypedCollectionDeserializationTestCase.cs#L24-L43
The text was updated successfully, but these errors were encountered: