SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 359 | Next

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

"Model-Based Software Testing and Analysis with C#"


The following example shows a case of an enabling condition based on the state
of other model elements. Note that feature interaction may occur if state defined
within one feature is referenced outside of that feature.
Appendices 283
namespace MyModelProgram
{
[Feature]
static class CreditsRestriction
{
static int nMsg = 0;
static bool ResetEnabled()
{
return (nMsg < 10 && Contract.MyStateVariable1);
}
[Action]
static void Reset()
{
nMsg += 1;
}
}
}
The factory method to instantiate this feature is the following:
namespace MyModelProgram
{
public static class Factory
{
public static ModelProgram Create()
{
return new LibraryModelProgram(typeof(Factory).Assembly,
"MyModelProgram",
new Set("CreditsRestriction"));
}
}
}
The features to be loaded are included as a Set-valued argument to the constructor.
All classes in the given assembly and namespace that contain a matching feature
attribute will be loaded as part of the model.
A.1.2 State variables
The state vocabulary of a model program consists of all fields declared within the
model program??™s namespace. Both instance and static fields are included. Public
284 Modeling Library Reference
and nonpublic fields are included. Fields inherited from base classes (even those
outside of the model namespace) are included.
Sometimes it is useful to exclude a field from state.


Pages:
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6