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.

Systems with Complex State 171<br />

Edit("bob", "file1", Op("Change"))<br />

Edit("alice", "file1", Op("Change"))<br />

Commit("alice")<br />

CommitComplete("alice", 2)<br />

Commit("bob")<br />

MustResolve("bob", Set("file1"))<br />

Resolve("bob", "file1")<br />

Commit("bob")<br />

CommitComplete("bob", 3)<br />

This trace shows a scenario where client alice adds a file named file1 to the<br />

repository and commits her change. Client bob synchronizes against the repository<br />

and begins to edit file1. Alice, in the meantime, edits file1 and commits her<br />

changes.<br />

When client bob commits, the system tells him that there is a conflict to resolve.<br />

He resolves the conflict with the Resolve action and commits again. The system<br />

responds with CommitComplete, indicating that the change has been incorporated<br />

into the repository. The repository increments its global revision number and reports<br />

it in the CommitComplete action.<br />

10.4.2 State and derived state<br />

<strong>We</strong> introduce just enough state to accurately determine which traces of the system<br />

are possible and which are not. For ease of understanding, we can separate state into<br />

the state of the repository and the state of the users of the repository.<br />

Global version<br />

namespace RevisionControl<br />

{<br />

partial static class Repository<br />

{<br />

public static int currentRevision = 0;<br />

}<br />

}<br />

In C# the keyword partial may be used to break up a class definition into several<br />

blocks. <strong>We</strong> use this here to indicate that blocks of code separated by explanatory<br />

text all belong to the same class.<br />

The state of the revision control system includes a global version number currentRevision.<br />

This represents number of times any change has been committed to<br />

the repository.<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!