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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Systems with Complex State 173<br />

Client state<br />

Clients of the revision control system have several elements of state. Since these<br />

occur on a per-client basis, we can use maps whose keys are client names.<br />

partial static class User<br />

{<br />

static Map version<br />

= Map.EmptyMap;<br />

}<br />

static Map revisions<br />

= Map.EmptyMap;<br />

static Map conflicts<br />

= Map.EmptyMap;<br />

static Set commitPending = Set.EmptySet;<br />

The version state variable records the version of the global repository that corresponds<br />

with the most recent commit operation. This is a per-client element of state<br />

because clients may synchronize with the global repository at different times. The<br />

ability of clients to take a snapshot of the repository’s state is an important feature<br />

of the revision conrol system.<br />

The revisions state variable records for each client which files contain pending<br />

edits for that client. The value is a map of file names to the current edit operation.<br />

The conflicts state variable is used when committing changes to the database.<br />

It contains a set of files with version conflicts. Such files must be resolved before a<br />

change may be committed to the repository.<br />

The commitPending state variable records whether a client is in the process<br />

of perfoming a commit operation. Client operations are disabled when there is a<br />

pending commit operation.<br />

Derived state<br />

The C# model program includes several elements of derived state. These are methods<br />

or properties that query the state but do not change it.<br />

partial static class User<br />

{<br />

static bool CommitPending(string user)<br />

{ return commitPending.Contains(user); }<br />

more free ebooks download links at:<br />

http://www.ebook-x.com

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

Saved successfully!

Ooh no, something went wrong!