28.3. Using SetFixtureLet's now consider the revised method usersInRoom() in Listing 28.4. This method instead makes use of SetFixture, a new fixture for testing unordered lists. This fixture reports in the same way as RowFixture but is more flexible. We can supply the actual collection as an argument to the constructor of SetFixture rather than having to subclass it. SetFixture TReats a header label as the name of a property if there is no instance variable of that name. Hence, it will call the method getName() of User objects. The interaction of the fixtures and the first five tables is illustrated in Figure 28.3. The collection supplied to the SetFixture object has a single User element. Figure 28.3. TestDisconnect with SetFigure
If a method call for an action in a flow fixture object returns a Set, DoFixture automatically creates a SetFixture with it and returns that fixture. Hence, we can remove the method usersInRoom() in Listing 28.4. Then, when the action users in room is carried out, it leads to a call of the method usersInRoom() in the system under test. Because this returns a Set, DoFixture automatically creates a SetFixture, which is used to interpret the rest of the table. Further details of SetFixture, and related list fixtures, are given in Section 28.9. |