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

}<br />

{<br />

}<br />

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

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

conflicts = conflicts.Add(user, Set.EmptySet);<br />

Synchronize may occur at any time except when there is a pending commit action<br />

for the given user. It is also possible to use Synchronize for a new user.<br />

A Synchronize action may occur after some files have been edited but before they<br />

have been committed to the repository. If the version of a file in the repository is<br />

more recent (i.e., is larger) than the version already modified, then a conflict occurs.<br />

The following method checks for such conflicts.<br />

partial static class User<br />

{<br />

static void IdentifyConflicts(string user, int currentVersion)<br />

{<br />

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

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

{<br />

string file = revision.First;<br />

Op op = revision.Second;<br />

}<br />

}<br />

if (!userConflicts.Contains(file) &&<br />

currentVersion < Repository.FileVersion(file) &&<br />

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

op != Op.Delete)<br />

userConflicts = userConflicts.Add(file);<br />

}<br />

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

When checking for conflicts, two helper methods are used to detect whether the<br />

repository has seen an update that conflicts with the currently edited version in the<br />

client.<br />

The FileVersion method returns the version number of the most recent checkin<br />

of a given file:<br />

partial static class Repository<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!