I'm refactoring our platform to use Community Toolkit's MVVM instead of the homebrew MVVM my company made years ago before everything was standardized. After the refactor, I have a couple of unit tests that were expecting a null in response to the GetErrors method used in the old MVVM. But the refactored method is currently returning
<System.Collections.Generic.List`1[System.ComponentModel.DataAnnotations.ValidationResult] >
When I change the unit test to:
Assert.AreEqual(System.ComponentModel.DataAnnotations.ValidationResult.Success, _accessor.GetErrors(nameof(_target.foo)));
It returns the result:
Assert.AreEqual failed. Expected:<(null)>. Actual:<System.Collections.Generic.List`1[System.ComponentModel.DataAnnotations.ValidationResult]>.
This suggests that ValidationResult.Success is interpreted as null, but that's not what's being returned, even though I verified that my validation code is going down the path that should return ValidationResult.Success on a logical level.
Why is GetErrors returning this result, and what do I do about it?