15.4. Business TransactionsIt was time for Sarah, Emily, and Don to deal with the money, but they weren't sure of all the details. So Mitra, a business analyst, was asked to join the group to help with that and to gain experience with Fit tests. As Mitra explained: "Customers may start saying what they want to rent, which is entered by the staff member serving them. But when they find that some item is not available, they may cancel everything. We have to ensure that they get the rental items if they want them, so we handle this with a business transaction." "And they can cancel part of it at any time," Don added. "So we need some way of handling that in our tests." "For a transaction to be completed," Mitra continued, "customers have to have paid or had the amount added to their charge accounts. To cancel after they've paid, they have to first have that payment refunded, or it will be automatically removed as a charge on their accounts." "So we need to be explicit about the transaction as a business object in our test," said Sarah, "so how about this for the action part of the test?" She sketched out the tables in Figure 15.8: "I've put all the actions to do with the transaction into a single table, as they operate within the context of that transaction."
Questions & Answers
"There's no need to check the total before and after paying," Mitra recommended. "If the payment isn't for the full amount of the rental cost, the transaction cannot be completed. And the transaction mentions the customer, so there's no need to do that separately in the SetUp." "We'll need to write some tests for the transaction failing to complete," added Don. "Let's leave that until later." (We cover that in the next section.) Sarah changed the SetUp to include information about staff, as shown in Figure 15.9. Figure 15.9. Revised SetUp
She then removed the amount checks from Figure 15.8, resulting in the test shown in Figure 15.10, which assumes the SetUp in Figure 15.9, as usual. The last table in Figure 15.10 was also changed by Don to include staff member Bill in the transaction. Figure 15.10. Revised Test Rental Within a Transaction
|