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.

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

}<br />

}<br />

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

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

Commit checks for update conflicts and marks the user as “pending.” This will<br />

allow either of two possible actions to complete: MustResolve and CommitComplete.<br />

MustResolve action<br />

A client’s request to commit changes can only be propagated to the repository if<br />

there are no conflicts.<br />

partial static class User<br />

{<br />

static Set ResolveSets()<br />

{<br />

Set result = Set.EmptySet;<br />

foreach (string user in Users())<br />

if (commitPending.Contains(user))<br />

{<br />

Set fileConflicts = FileConflicts(user);<br />

if (!fileConflicts.IsEmpty)<br />

result = result.Add(fileConflicts);<br />

}<br />

return result;<br />

}<br />

static Set FileConflicts(string user)<br />

{<br />

Set result = conflicts[user];<br />

foreach (Pair revision in revisions[user])<br />

{<br />

string file = revision.First;<br />

Op op = revision.Second;<br />

}<br />

if (version[user] < Repository.FileVersion(file) &&<br />

Repository.FileExists(file) &&<br />

op != Op.Delete)<br />

result = result.Add(file);<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!