DateTime Should().BeLessThan(...).After(b) not check After
See original GitHub issueHello!
It seems strange for me that DateTimeAssertions works in this way:
[Test]
public void Test_before_and_after()
{
var a = new DateTime(2019, 01, 01, 12, 0, 0, DateTimeKind.Utc);
var b = new DateTime(2019, 01, 01, 12, 30, 0, DateTimeKind.Utc);
a.Should().BeLessThan(1.Hours()).Before(b);
a.Should().BeLessThan(1.Hours()).After(b);
}
These methods check that difference is less than value, and it is true when difference is negative. But is not correct to say that a
is less than an hour after b
when a - b == -30.Minutes()
I think there should be assertion that difference (TimeSpan actual
) should be not negative in methods DateTimeRangeAssertions.Before
and DateTimeRangeAssertions.After
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Issues
DateTimeAssertions.BeWithin and BeLessThan do not work if date is on the opposite side of reference date in .Before/.After #1467.
Read more >c# - Fluent Assertions: Using BeCloseTo on a collection of ...
As a direct answer to your question, you can do something like items.Should().OnlyContain(i => (i - DateTime.Now) < TimeSpan.FromMilliseconds( ...
Read more >Tips - Fluent Assertions
By having Should() as early as possible in the assertion, we are able to include more information in the failure messages.
Read more >datetime — Basic date and time types
A datetime object d is aware if both of the following hold: d.tzinfo is not None. d.tzinfo.utcoffset(d) does not return None. Otherwise, d...
Read more >Fluent Assertions - RSSing.com
As explained in this article, floating point variables are inheritably inaccurate and should never be compared for equality. Instead, either use the Should()....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jnyrup @dennisdoomen
I’ve created a PR for this request. Can you take a look whenever you guys get a chance?
#1313
@jonathann92 To our knowledge no one is working on this issue, but we’re open to contributions.