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.

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

}<br />

public static int FileVersion(string file)<br />

{<br />

Sequence revisions;<br />

return (db.TryGetValue(file, out revisions) ?<br />

revisions.Head.revisionNumber : -1);<br />

}<br />

The FileExists method checks whether a given file is in the repository, and if<br />

so, whether the last operation for that file was Add or Change.<br />

partial static class Repository<br />

{<br />

public static bool FileExists(string file, int version)<br />

{<br />

Sequence revisions;<br />

if (db.TryGetValue(file, out revisions))<br />

foreach (Revision r in revisions)<br />

if (r.revisionNumber

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!