Skip to content

Add .BeCloseTo()/.NotBeCloseTo() to TimeOnlyAssertions and DateOnlyAssertions #2029

@jhartmann123

Description

@jhartmann123

Description

Similar to the DateTimeAssertions, the method BeCloseTo() should be available for TimeOnly and DateOnly.

E.g.

// Arrange
SetTime("10:00:12");
var expected = new TimeOnly(10, 0, 12);

// Act
TimeOnly time = GetTime();

// Assert
result.Should().BeCloseTo(expected, TimeSpan.FromSeconds(1));

Expected behavior:

Validation, if the variable expected is >= 10:00:11 and <= 10:00:13

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions