15.2. Charging a DepositThe general business rule here is as follows.
The group's first step was to add deposit information in the SetUp to the Hire-Items, as last shown in Figure 14.6 on p. 110. After some debate, Don made the deposit $0.00 for the two dispensers; that meant that the previous tests should still pass. As Don argued, "It would be great if we could add more data to the SetUp without breaking the old tests." The others agreed. Don added cups as an item with a deposit and included the three rental rates: hourly, daily, and weekly, as shown in Figure 15.1. Figure 15.1. Extend the SetUp
Sarah wrote the test shown in Figure 15.2. She then questioned whether it made sense to have only a weeks column in those tables: "Will we need hours, days, and weeks ?" "Let's wait until we add date/time processing and see what happens," Emily suggested. Figure 15.2. Rent with a Deposit
"This test is incomplete," Don then pointed out. "We should also check that there are 100 fewer cups in stock afterward." He extended Figure 15.2 to give Figure 15.3. Figure 15.3. Rent with a Deposit with Extra Checking Table
Immediately, Don was unhappy with that: "We need to check only the count." Emily added, "And we'd be better checking just the cups, not the other items. Otherwise, when we change the SetUp again, the last table (in Figure 15.3) will fail." Don changed the table to give Figure 15.4, using a SubsetFixture.[1] He pointed out, "We'll need to have at least one test that checks that the other rental items are not altered at all."
Figure 15.4. Revised Last Table
"We need to write a test for returning the deposit when the rental items are returned," Emily noted. However, she realized, "We really haven't handled payments yet, let alone refunds. Let's leave that until after we do dates." Questions & Answers
|