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.

200 <strong>Testing</strong> Systems with Complex State<br />

using System;<br />

using N<strong>Model</strong>.Conformance;<br />

using N<strong>Model</strong>.Terms;<br />

namespace BagImplTestHarness<br />

{<br />

public class Stepper : IStepper<br />

{<br />

}<br />

}<br />

BagImpl bag = new BagImpl.BagImpl();<br />

public Action DoAction(Action a)<br />

{<br />

switch (a.Name)<br />

{<br />

case ("Add"):<br />

bag.Add((string)a[0]);<br />

return null;<br />

case ("Delete"):<br />

bag.Delete((string)a[0]);<br />

return null;<br />

case ("Lookup_Start"):<br />

int c = bag.Lookup((string)a[0]);<br />

return Action.Create("Lookup_Finish", c);<br />

case ("Count_Start"):<br />

return Action.Create("Count_Finish", bag.Count);<br />

default :<br />

throw new Exception("Unexpected action " + a);<br />

}<br />

}<br />

public void Reset()<br />

{<br />

bag = new BagImpl();<br />

}<br />

Figure 12.4. Bag stepper.<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!