Hello World
Stepping back to one of our first examples, take a look at the sample Hello World application. Remember that, depending on the time of day, a different message is displayed to the user. Before noon, the user is greeted with Good morning
, and after noon, Good afternoon
is returned to the user.
A change in requirements
Depending on the time of day, the user is greeted with Good morning
or Good afternoon
. To extend the functionality and introduce a new feature, let's address the user with Good evening
if the time of day is between 6 p.m. and midnight.
Good evening
In order to introduce this new feature, begin with the tests. Modification of an existing test will be needed, as well as adding one or more new tests to cover the change in requirements.
Modify the Theory
data provided to GivenAfternoon_ThenAfternoonMessage
so that only noon through 6 p.m. are included for this test. Now, create a new test method, GivenEvening_ThenEveningMessage
:
[Theory] [InlineData(19)] [InlineData(20)]...