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.

Advanced Topics 243<br />

values "Inactive", "Activating", or"Active". Initially the value of setupMode is<br />

"Inactive". The guarded update rule for ResSetup in M = M1 × M2 can be given<br />

as<br />

[Action("ResSetup(m,_,s)")]<br />

public static void ResSetup(int m, Status s)<br />

{<br />

mode = mode.RemoveKey(m);<br />

if (s == Status.Cancelled)<br />

setupMode = "Inactive";<br />

else<br />

setupMode = "Active";<br />

}<br />

public static bool ResSetupEnabled(int m, Status s)<br />

{<br />

return<br />

setupMode == "Activating" &&<br />

mode.ContainsKey(m) &&<br />

(s != Status.Cancelled || mode[m] == Mode.CancelRequested);<br />

}<br />

The guarded update rule for ResWork in M1 × M2 can be given as<br />

[Action("ResWork(m,_,s)")]<br />

public static void ResWork(int m, Status s)<br />

{<br />

mode = mode.RemoveKey(m);<br />

}<br />

public static bool ResWorkEnabled(int m, Status s)<br />

{<br />

return<br />

setupMode == "Active" &&<br />

mode.ContainsKey(m) &&<br />

(s != Status.Cancelled || mode[m] == Mode.CancelRequested);<br />

}<br />

In M1 × M2 the guarded update rule of Cancel is the same as in M2, because in M1<br />

Cancel is a self-loop. The following is a trace of M1 × M2:<br />

ReqSetup(3)<br />

ResSetup(3,_,STATUS("Completed"))<br />

ReqWork(7)<br />

Cancel(7)<br />

ResWork(7,_,STATUS("Completed"))<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!