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.

Appendices 283<br />

namespace My<strong>Model</strong>Program<br />

{<br />

[Feature]<br />

static class CreditsRestriction<br />

{<br />

static int nMsg = 0;<br />

}<br />

}<br />

static bool ResetEnabled()<br />

{<br />

return (nMsg < 10 && Contract.MyStateVariable1);<br />

}<br />

[Action]<br />

static void Reset()<br />

{<br />

nMsg += 1;<br />

}<br />

The factory method to instantiate this feature is the following:<br />

namespace My<strong>Model</strong>Program<br />

{<br />

public static class Factory<br />

{<br />

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

{<br />

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

"My<strong>Model</strong>Program",<br />

new Set("CreditsRestriction"));<br />

}<br />

}<br />

}<br />

The features to be loaded are included as a Set-valued argument to the constructor.<br />

All classes in the given assembly and namespace that contain a matching feature<br />

attribute will be loaded as part of the model.<br />

A.1.2 State variables<br />

The state vocabulary of a model program consists of all fields declared within the<br />

model program’s namespace. Both instance and static fields are included. Public<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!