Logo BCDDLogo CSC
BCDDBehavioural Contract-Driven Design
version 1.0-beta
ITEN

Chapter 18 — Scenarios on several boundaries

The scenarios of part one (chapters 1-10) name elements of a single boundary. With the division of chapter 11 the scenarios s1, s2 and s3, which name both the press and the light, can no longer be written in either of the two CSCs. This chapter describes where they are written: in the entity.

The entity scenario

An entity scenario is a scenario written in an entity, in which every name of an event, state or request is preceded by the name of the CSC it belongs to and by a full stop: Pressione.premuto, Luce.modo. A name written in this form is called a qualified name.

A CSC describes only its own boundary and cannot establish an order between what happens on two different boundaries. The entity provides or uses both boundaries, and the entity scenario is the form in which that order is written.

In the entity LuceScale of chapter 13 four scenarios are added, after the entity guarantees:

  SCENARIO ls-s1 EXPECT ADMITTED
    @0 s     Pressione.premuto
    @1 s     Luce.modo = accesa
  SCENARIO ls-s2 EXPECT ADMITTED
    @0 s     Pressione.premuto    Luce.modo = accesa
    @85 s    Luce.avviso
    @90 s    Luce.modo = spenta
    @100 s   Pressione.premuto    Luce.modo = accesa
  SCENARIO ls-s3 EXPECT REJECTED
    @0 s     Pressione.premuto    Luce.modo = accesa
    @30 s    Luce.modo = spenta
  SCENARIO ls-s4 GIVEN Luce.modo = in_pulizia EXPECT ADMITTED
    @0 s     Pressione.premuto    Luce.modo = in_pulizia
END

The scenario ls-s1 reads: at instant 0 the button is pressed and at instant 1 the light is on. The scenarios ls-s2, ls-s3 and ls-s4 are the scenarios s1, s2 and s3 of UsoLuce, rewritten with the qualified names and with the switch-off time of 90 seconds.

In other respects an entity scenario is written like a CSC scenario (chapter 9): instants in chronological order, starting state with GIVEN, expected outcome with EXPECT. An entity scenario is an example, not an obligation: it is not a contractual line and it does not forbid what it does not describe. It establishes neither an order between the parts nor a priority, and it does not describe a channel: it reports what is observed on the boundaries of the entity.

What bcdd checks

$ bcdd check --strict LuceScale.csc
bcdd check --strict LuceScale.csc
lines: 35 (recognised 29, comments 1, blank 5, unrecognised 0)
…
1. ERRORS: 0
…
outcome: no errors

For each qualified name X.y bcdd checks two conditions: that X is a CSC provided or used by the entity, and that the CSC X contains the element y of the expected kind. The expected kind is a state in Luce.modo = accesa, an event in Pressione.premuto, a request between the parentheses of a lifecycle phase. It also checks the parameters of the events and the chronological order of the instants, as in the CSC.

An entity scenario names only the public boundaries of the entity, never the internal boundaries between its parts.

Summary

Special cases

Internal boundary. If the scenario names Comando.accendi, an event of the boundary between the parts:

1. ERRORS: 1
  line 23: [E20] Comando.accendi: LuceScale neither provides nor uses connector Comando; a scenario can cite only the connectors of LuceScale

Element not declared in the CSC. With Luce.premuto in place of Pressione.premuto:

1. ERRORS: 1
  line 23: [E03] name not declared as EVENT: Luce.premuto

Name without the CSC. With premuto in place of Pressione.premuto: an entity has no elements of its own, and the name is not declared.

1. ERRORS: 1
  line 23: [E03] name not declared as EVENT: premuto

Value not included in the list of values. With Luce.modo = buia the report shows no errors: in entity scenarios bcdd does not read the lists of values of the cited CSCs and does not check values that are names. It does, however, check literal values (numbers, strings, true and false) when the type of the element in the cited CSC is a base type. Checking a value that is a name is the responsibility of whoever writes.

Cited CSC not found. If the file Luce.csc is missing, the citation appears in section 7 and the names Luce.… of the scenarios are not checked.