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 179<br />

}<br />

return result;<br />

static bool MustResolveEnabled(string user, Set files)<br />

{<br />

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

!files.IsEmpty && Object.Equals(files,<br />

FileConflicts(user));<br />

}<br />

[Action]<br />

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

[Domain("ResolveSets")] Set files)<br />

{<br />

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

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

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

}<br />

}<br />

}<br />

Resolve action<br />

The Resolve action reconciles differences between a local edited version of a file<br />

and a parallel update on the server. Of course, in the model we don’t deal with the<br />

actual contents of the file; instead, we examine the conditions that must occur in<br />

order for the resolve operation to occur.<br />

partial static class User<br />

{<br />

static bool ResolveEnabled(string user, string file)<br />

{<br />

return (CanStep(user) && conflicts[user].Contains(file));<br />

}<br />

}<br />

[Action]<br />

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

{<br />

Set remainingFiles = conflicts[user].Remove(file);<br />

conflicts = conflicts.Override(user, remainingFiles);<br />

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