16.2. Testing Calculations InsteadEmily sketched out the test shown in Figure 16.3. As Seth pointed out, "This could be used for late returns as well."
After adding some rows, Don suggested, "Why don't we simply write the hours, and so on, in directly? It's a pain working out the time differences from the dates." This led to the test shown in Figure 16.4. "The columns hours1, days1, and weeks1 give the time period that was paid for, and hours2, and so on, give the time before returning the rental items."
"That makes the table very wide. We could get rid of the left three columns by providing them to the table as a whole," suggested Emily. This resulted in the test shown in Figure 16.5.
Emily then suggested, "Let's split up the tables so we need to include only some columns; the rest we can assume to be 0. And let's be clear about what the rates are for in the first row. Let's use a DoFixture table to do that." This resulted in the tests shown in Figure 16.6. Figure 16.6. Split Tables
Sarah then pointed out, "The refund calculation is one step removed from the underlying business rule: Which time period is fairer to use? To calculate the refund or the extra charge, we need to calculate the cost for the actual time period and subtract it from the original charge. So let's focus the test on the time periods." She then drew out some tables using this approach, as shown in Figure 16.7. Figure 16.7. Fair Charge Tables
|