PartitionKey.Equals throws NullReferenceException
See original GitHub issueDescribe the bug
PartitionKey.Equals
throws NullReferenceException
for default(PartitionKey).
To Reproduce
var b = default(PartitionKey).Equals(default(PartitionKey))
Alternatively, use NSubstitute for unit testing and set up a return value for CreateItemAsync
with Arg.Any<PartitionKey>()
for the PartitionKey
condition.
Expected behavior
Should not throw a NullReferenceException
.
default(PartitionKey).Equals()
should correctly evaluate against the parameter without throwing an exception.
Actual behavior Throws NullReferenceException
Environment summary SDK Version: NETStandard.Library 2.0.3 OS Version (e.g. Windows, Linux, MacOSX): Windows 10 Pro
Additional context I recently updated to Microsoft.Azure.Cosmos 3.7.0 and this has broken a number of my unit tests, as it fails during test setup.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
OK, sorry. I picked the wrong dot in my assumption.
I looked at the PR referenced, and it doesn’t actually address this specific problem, other than some discussion and an apparent dismissal.
Also, the unit tests in that PR should probably add some checks where the left-side operand is default(PartitionKey), PartitionKey.None, and PartitionKey.Null for completeness.
Edited the original post to correct the assumption as to root cause.