Skip to content

Add DateTime/TimeSpan support for inequality tolerance #4600

@RenderMichael

Description

@RenderMichael

It would be nice if the following code worked:

public static DateTime LastDateAccessed { get; set; } // simulate a remote value

[Test]
public void TestMe()
{
    DateTime beforeUpdate = DateTime.UtcNow;

    // Do operation
    LastDateAccessed = DateTime.UtcNow.AddMilliseconds(-50); // some kind of timing imperfection on the server

    // This fails because of the timing issue
    Assert.That(LastDateAccessed, Is.GreaterThan(beforeUpdate));

    // It would be nice to do this
    Assert.That(LastDateAccessed, Is.GreaterThan(beforeUpdate).Within(TimeSpan.FromSeconds(1)));
}

For consistency, this should probably be done on all constraints that extend ComparisonConstraint.

I am willing to take up the task. I just want to make sure this is kind of change would be accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions