Skip to content
New issue

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

MSTEST0037 testing operators == and != #4414

Open
avivanoff opened this issue Dec 20, 2024 · 1 comment
Open

MSTEST0037 testing operators == and != #4414

avivanoff opened this issue Dec 20, 2024 · 1 comment

Comments

@avivanoff
Copy link

If you have a class that overloads operators == and !=, writing the proper unit tests results in MSTEST0037: Use proper 'Assert' methods:

public sealed class SomeClass
{
    public static Boolean operator ==(SomeClass left, SomeClass right)
    {
        ...
    }

    public static Boolean operator !=(SomeClass left, SomeClass right)
    {
        ...
    }
}

[TestMethod]
public void SomeClass_TestOperatorEquals()
{
var left = new SomeClass(...);
var right = new SomeClass(...);
Assert.IsTrue(laft == right); // MSTEST0037
}

@Youssef1313
Copy link
Member

Thanks for reporting this.

This was explicitly mentioned in the analyzer docs. But I think the analyzer could be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants