Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

3.4 Selecting a Phone Number

Our third example illustrates the use of simple lists in tests. The business rule for this example is very simple.

The first phone number in the list of supplied phone numbers will normally be used for communicating with the client.

A single test is shown in Figure 3.5. The phones column contains a comma-separated list of phone numbers. The calculated column first() selects the first one in the list.

Table 3.5. Fit Table for Testing First Phone

CalculateFirstPhoneNumber

phones

first()

(209)373 7453, (209)373 7454

(209)373 7453

When the elements of a list are more complex, such as containing details of each order item within an order, this approach doesn't work. A RowFixture table can be used instead, as discussed in Chapter 5.

Questions & Answers

  1. What if an element in the list contains a comma (,)?

    In that case, a RowFixture tables could be used, as covered in Chapter 5. If you wanted to use such lists in a ColumnFixture, a programmer would need to write some fixture code to handle that specially, as we discuss in Chapter 25.

  2. What happens if the phone list is empty?

    The business rule doesn't cover that situation, but it does need to be defined. We take up this issue in Chapter 9, when we talk about handling various expected errors.

  • + Share This
  • 🔖 Save To Your Account