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.

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

}<br />

static bool IsUser(string user)<br />

{ return version.ContainsKey(user); }<br />

static bool CanStep(string user)<br />

{ return IsUser(user) && !CommitPending(user); }<br />

static Set Users()<br />

{ return version.Keys; }<br />

The CommitPending method says whether a given user is waiting for a Commit<br />

action to respond.<br />

The IsUser method determines whether the string given as its argument has<br />

appeared in at least one Synchronize action.<br />

The CanStep method says whether the client actions Commit, Resolve, Edit, and<br />

Revert can be taken. This is true if the user has performed at least one checkout<br />

action and is not waiting for a pending commit action.<br />

Synchronize action<br />

The Synchronize action brings a client’s view of the repository up to date with<br />

respect to the server. The practical effect of this is to set the version number of the<br />

client to be equal to the repository’s revision number.<br />

partial static class User<br />

{<br />

static bool SynchronizeEnabled(string user)<br />

{<br />

return !CommitPending(user);<br />

}<br />

[Action]<br />

static void Synchronize(string user)<br />

{<br />

int newVersion = Repository.currentRevision;<br />

if (IsUser(user))<br />

{<br />

IdentifyConflicts(user, version[user]);<br />

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

}<br />

else<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!