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.

266 Reactive Systems<br />

namespace SPImpl<br />

{<br />

public class Stepper : IAsyncStepper<br />

{<br />

ObserverDelegate Respond;<br />

Server server = new Server();<br />

}<br />

}<br />

public void SetObserver(ObserverDelegate obs)<br />

{<br />

Respond = obs;<br />

server.ResponseEvent += new ResponseEventDelegate(Responder);<br />

}<br />

void Responder(string cmd, int id, int credits, Status status)<br />

{<br />

Action response = Action.Create("Res" + cmd, id, credits, status);<br />

Respond(response);<br />

}<br />

public Action DoAction(Action a)<br />

{<br />

switch (a.Name)<br />

{<br />

case ("ReqSetup"):<br />

server.Request("Setup", (int)a[0], (int)a[1]);<br />

return null;<br />

case ("ReqWork"):<br />

server.Request("Work", (int)a[0], (int)a[1]);<br />

return null;<br />

default: throw new Exception("Unknown action: " + a);<br />

}<br />

}<br />

public void Reset()<br />

{ if (server.IsBusy) throw new Exception("Server is busy"); }<br />

public static IAsyncStepper Make() { return new Stepper(); }<br />

Figure 16.5. Asynchronous stepper of an SP server.<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!