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.

Systems with Complex State 197<br />

using System.Collections.Generic;<br />

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

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

namespace Bag<strong>Model</strong><br />

{<br />

[Feature]<br />

static class ElementRestriction<br />

{<br />

readonly static Set E = new Set(null,"","b");<br />

}<br />

}<br />

[Action]<br />

static void Add([Domain("E")]string e)\verb+{}+<br />

[Action]<br />

static void Delete([Domain("E")]string e)\verb+{}+<br />

[Action]<br />

static void Lookup_Start([Domain("E")]string e)\verb+{}+<br />

[AcceptingStateCondition]<br />

static bool IsAcceptingState() {return Contract.content.IsEmpty;}<br />

public static class Factory<br />

{<br />

public static <strong>Model</strong>Program CreateScenario()<br />

{<br />

return new Library<strong>Model</strong>Program(typeof(Contract).Assembly,<br />

"Bag<strong>Model</strong>", new Set("ElementRestriction"));<br />

}<br />

}<br />

Figure 12.3. A feature of the bag model and a scenario including the feature.<br />

The factory method CreateScenario creates a restricted model where the input<br />

parameters to the actions are restricted to the given elements. The method uses<br />

the Library<strong>Model</strong>Program constructor that takes an assembly, a namespace that<br />

identifies a model program in the assembly, and a set of feature names within that<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!