..
}
To analyze a model, or generate test cases, the arguments of every parameter of
every action method must be drawn from a finite collection called a domain. Parameters
with boolean types or enumerated types always have finite domains. Other
parameters must be labeled with a Domain attribute. The argument of the attribute,
"Temperatures" here, is a string that names a method in the same class that returns
82 Model Programs
the set of argument values for the parameter. When a tool executes the action method,
it will choose one element from this set to assign to that parameter. A domain can
also be a field or a property. The domain can depend on the state (it can return
different sets of values in different states).
static Set
Temperatures()
{
return new Set(Temp1, Temp2);
}
Here the domain method always returns the same set. A domain method can return a
set that is computed from the state. Set is a C# generic collection type that is provided
by the modeling library (Chapter 10). Here identifies the type of the
elements of the set, which must match the type of the parameter in the action method.
In this example we code the domain in the model. In Chapter 7 we show how to
code the domain separately from the model (which makes it easier to use different
domains with the same model).
Now that we have a model program, we must validate it.
Pages:
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130