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.

180 <strong>Model</strong>ing Systems with Structured State<br />

CommitComplete action<br />

If a Commit action is pending and there are no conflicts, then the repository is able<br />

to incorporate the proposed changes. The successful update is represented by the<br />

CommitComplete action.<br />

partial static class User<br />

{<br />

static Set NextVersion()<br />

{<br />

return new Set(Repository.currentRevision,<br />

Repository.currentRevision + 1);<br />

}<br />

}<br />

static bool CommitCompleteEnabled(string user, int newVersion)<br />

{<br />

return IsUser(user) && CommitPending(user)<br />

&& conflicts[user].IsEmpty<br />

&& newVersion == (revisions[user].IsEmpty<br />

? Repository.currentRevision<br />

: (Repository.currentRevision + 1));<br />

}<br />

[Action]<br />

static void CommitComplete([Domain("Users")] string user,<br />

[Domain("NextVersion")] int newVersion)<br />

{<br />

Map userRevisions = revisions[user];<br />

}<br />

version = version.Override(user, newVersion);<br />

revisions = revisions.Override(user,Map.EmptyMap);<br />

commitPending = commitPending.Remove(user);<br />

Repository.Commit(user, "Check in", userRevisions);<br />

In later chapters we will show how the model of revision control system can be<br />

used to predict behavior. For now, let’s just consider one scenario.<br />

If you look at the scenario given above in Section 10.4.1, you may notice that<br />

user bob had other ways to resolve the conflict. <strong>We</strong> can use the model to enumerate<br />

what the possible outcomes might have been. These are shown in Figure 10.1. The<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!