Skip to content

MSTEST0037 not reported for (alll) types that implement IComparable<T> #6591

@drieseng

Description

@drieseng

In MSTest v3.10.4, MSTEST0037 is currently not reported for all types that implement IComparable.

Steps To Reproduce

Compile the following code (with MSTest analyzers enabled):

using System;

using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public sealed class MSTEST0037Tests
{
    [TestMethod]
    public void TimeSpanComparison()
    {
        var ts1 = TimeSpan.Zero;
        var ts2 = TimeSpan.Zero;

        Assert.IsTrue(ts2 > ts1);
        Assert.IsTrue(ts2 >= ts1);
        Assert.IsTrue(ts2 < ts1);
        Assert.IsTrue(ts2 <= ts1);
        Assert.IsTrue(ts2 == ts1);
        Assert.IsTrue(ts2 != ts1);
    }

    [TestMethod]
    public void DateTimeComparison()
    {
        var ts1 = DateTime.Today;
        var ts2 = DateTime.Today;

        Assert.IsTrue(ts2 > ts1);
        Assert.IsTrue(ts2 >= ts1);
        Assert.IsTrue(ts2 < ts1);
        Assert.IsTrue(ts2 <= ts1);
        Assert.IsTrue(ts2 == ts1);
        Assert.IsTrue(ts2 != ts1);
    }
}

Expected behavior

MSTEST0037 is reported for each usage of Assert.IsTrue(...).

Actual behavior

MSTEST0037 is not reported at all.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions