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

namespace SP<br />

{<br />

[Feature]<br />

public static class CreditScenario<br />

{<br />

static readonly Set C = new Set(2);<br />

static Set M()<br />

{<br />

if (Credits.window.IsEmpty)<br />

return Set.EmptySet;<br />

else<br />

return new Set(Credits.window.Minimum());<br />

}<br />

}<br />

[Action("ReqSetup(m,c)")]<br />

[Action("ReqWork(m,c)")]<br />

static void Req([Domain("M")]int m, [Domain("C")]int c) { }<br />

static bool ReqEnabled(int m) { return m < 3; }<br />

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

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

static void Res(int m, int c){}<br />

static bool ResEnabled(int m, int c)<br />

{<br />

return Credits.requests.ContainsKey(m) &&<br />

Credits.requests[m] == c;<br />

}<br />

}<br />

[Feature]<br />

public static class CancelScenario<br />

{<br />

static Set M()<br />

{<br />

if (Cancellation.mode.Keys.Count < 2)<br />

return Set.EmptySet;<br />

else<br />

return new Set(Cancellation.mode.Keys.Minimum());<br />

}<br />

}<br />

[Action]<br />

static void Cancel([Domain("M")]int m) { }<br />

static bool CancelEnabled(int m)<br />

{<br />

return Cancellation.mode[m] == Mode.Sent;<br />

}<br />

Figure 14.16. Two scenarios for the composition with the protocol features.<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!