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

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

Closed
jhartmann123 opened this issue Nov 7, 2022 · 1 comment · Fixed by #2030
Closed

Comments

@jhartmann123
Copy link

jhartmann123 commented Nov 7, 2022

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

@jnyrup
Copy link
Member

jnyrup commented Nov 7, 2022

We intentionally left them out from DateOnly as you cannot measure the time difference between two dates.

But I think it makes sense to add it for TimeOnly.

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

Successfully merging a pull request may close this issue.

2 participants