AB#112: Fixed a bug where Age returned 1 year less than expected. #113
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Description
This fixes the Age property to return the correct age. See linked Issue for more details.
I have included a new test 'TestEdgeCasesAroundBirthday' that demonstrates the faulty behaviour with the previous implementation, and verifies the correct behaviour with the new implementation.
Note:
If we just change the Age implementation we will break all the tests for 'TestAge'.
However, It's my understanding that these tests are actually faulty and expects the wrong age. I.e the second testdata gets '200002292399' as input SSN and expects that person to be '25' years old.. that however is wrong since the 'TestTimeProvider' returns '2025-01-01'. This person has not yet had his birthday this year and therfor is 24 years old. All the inputdata for this test has the same issue.
I "solved" it by changing so that 'TestTimeProvider' returns 2025-10-05. Then all data for the tests has actually had their birthday, and it gives 'TestEdgeCasesAroundBirthday' an opportunity to check edgecases around the birthdays.
If I have misunderstood the previous tests or made wrong assumptions, let me know and I can try to fix it 😃
Related issue
#112
Motivation
To hopefully make things better 😄
Checklist