27.07.2013 Views

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A <strong>Model</strong>ing Library<br />

Reference<br />

A model program created from C# source consists of actions and variables defined<br />

by the types declared in a single namespace. The namespace name is the model<br />

program name. For example:<br />

namespace My<strong>Model</strong>Program<br />

{<br />

static class Contract<br />

{<br />

static bool MyStateVariable1 = true;<br />

}<br />

}<br />

[Action]<br />

static void Reset() { /* ... */ }<br />

class Client : LabeledInstance<br />

{<br />

bool isEntered = false;<br />

// ...<br />

}<br />

The model program named My<strong>Model</strong>Program has two state variables, MyState-<br />

Variable1 and isEntered, as well as one action named Reset. The isEntered state<br />

variable can be seen as a field map of Client object IDs to Boolean values, since it<br />

has a value for each instance of the class.<br />

The tools require you to provide a factory method as a command-line argument.<br />

The factory method should be a static public method with return type <strong>Model</strong>Program.<br />

For example,<br />

more free ebooks download links at:<br />

http://www.ebook-x.com<br />

281

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!