Skip to content

MSTEST0037 testing operators == and != #4414

@avivanoff

Description

@avivanoff

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
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions