date time range assertions - asserting difference is not negative#1313
Conversation
|
Thanks for looking in this issue 👍 I like the idea about replacing Could this be simplified by moving the ts1 >= TimeSpan.Zero && ts1 > ts2Then if |
dennisdoomen
left a comment
There was a problem hiding this comment.
Great work. I just have a couple of wording/terminology remarks to address.
And would you be willing to also update the release notes at https://github.com/fluentassertions/fluentassertions/blob/develop/docs/_pages/releases.md?
Src/FluentAssertions/Primitives/DateTimeOffsetRangeAssertions.cs
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| [Fact] | ||
| public void When_asserting_subject_be_morethan_10_seconds_after_target_but_subject_is_before_target_should_throw() |
There was a problem hiding this comment.
(Nitpicking) Missing _ between more and than
There was a problem hiding this comment.
I was debating if i should have a be_more_than or bemorethan because the method name is BeMoreThan but somehow I went in the middle lol. I'll put an underscore to between the words.
There was a problem hiding this comment.
Don’t refer to technical names such as the names of methods, variables and UI elements in the name of a test. In my opinion, the name of a test should explain the functional scenario, whereas the cause and effect should clearly illustrate the technicalities of that scenario. If some class or member is renamed, it shouldn’t affect the functional name of the test.
In other words, I never use the literal name of a specific method in a test name.
| public void When_asserting_subject_be_morethan_10_seconds_after_target_but_subject_is_before_target_should_throw() | ||
| { | ||
| // Arrange | ||
| var target = 1.January(0001).At(0, 0, 30); |
There was a problem hiding this comment.
Instead of target we use the term expectation everywhere.
There was a problem hiding this comment.
@dennisdoomen We do use target elsewhere in DateTimeOffsetAssertionSpecs.cs and DateTimeAssertionSpecs.cs.
@jonathann92 If you change this to expectation, I'll clean up the others.
There was a problem hiding this comment.
@jnyrup I can change target to expectation in the files I touched. Would you guys also like to me to change it in DateTimeOffsetRangeAssertions.cs and DateTimeOffsetRangeAssertions.cs?
My reasoning for using Also ahead can mean "before" in some contexts other than time and this can lead to confusion. For example, there are 2 people in a line:
Did you still want it be |
I'm not a native speaker, but somehow it feels wrong. I'm wondering what is the correct English wording. Giving you're from CA, I guess you should know better than me. |
|
The no native speaker disclaimer applies to me as well. "but it is before by 2 ms" sounds like a mix of I think behind/ahead is used with time if e.g. your watch is out of sync, then |
|
Ok it makes sense when we're talking about times. I changed the messaging to ahead/behind instead of after/before. |
|
Are you willing to also update the release notes? |
jnyrup
left a comment
There was a problem hiding this comment.
This looks great!
Only a few minor comments from here
| public void When_asserting_subject_be_morethan_10_seconds_after_target_but_subject_is_before_target_should_throw() | ||
| { | ||
| // Arrange | ||
| var target = 1.January(0001).At(0, 0, 30); |
There was a problem hiding this comment.
@dennisdoomen We do use target elsewhere in DateTimeOffsetAssertionSpecs.cs and DateTimeAssertionSpecs.cs.
@jonathann92 If you change this to expectation, I'll clean up the others.
| var subject = 1.January(0001).At(0, 0, 15); | ||
|
|
||
| // Act / Assert | ||
| Action action = () => subject.Should().BeMoreThan(10.Seconds()).After(target); |
There was a problem hiding this comment.
Please structure this as
// Act
Action action = ...
// Assert
action.Should()...
(If my regex-fu serves me well, we follow this pattern everywhere)
There was a problem hiding this comment.
We do use target elsewhere in DateTimeOffsetAssertionSpecs.cs
@jnyrup legacy code ;-)
| } | ||
|
|
||
| [Fact] | ||
| public void When_asserting_subject_be_morethan_10_seconds_after_target_but_subject_is_before_target_should_throw() |
There was a problem hiding this comment.
| public void When_asserting_subject_be_morethan_10_seconds_after_target_but_subject_is_before_target_should_throw() | |
| public void When_asserting_subject_to_be_more_than_10_seconds_after_target_but_subject_is_before_target_it_should_throw() |
I'll clean up the other methods not using it_should_throw
| return new AndConstraint<TAssertions>(parentAssertions); | ||
| } | ||
|
|
||
| private static string PositionRelativeToTarget(DateTimeOffset actual, DateTimeOffset target) |
There was a problem hiding this comment.
| private static string PositionRelativeToTarget(DateTimeOffset actual, DateTimeOffset target) | |
| private static string PositionRelativeToTarget(DateTime actual, DateTime target) |
Does this wording sound right? |
|
@jonathann92 I would write it in past tense, since it's now fixed. |
Taking from the original bug report: |
b5ed3a5 to
7aead48
Compare
|
@jonathann92 again, thanks for taking the time to look this issue and contributing a fix ❤️ |
|
Kudos for @jonathann92 indeed. With all these contributions, 6.0 is going to be awesome. |
IMPORTANT
Fixing issue where assertion on
DateTimeRangewill fail onBeLessThanorBeWithinwhen the subject and target has a negative delta.Reported in #1165