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.

122 Structuring <strong>Model</strong> Programs with Features and Composition<br />

namespace ClientServer<br />

{<br />

...<br />

static class ClientServer<br />

{<br />

// State variables, methods used by all features<br />

...<br />

[Action]<br />

static void ServerSend(double datum) // No [Domain], use features instead<br />

...<br />

}<br />

}<br />

[Feature]<br />

static class TemperatureX2<br />

{<br />

readonly static Set Temperatures = new Set(99.9, 100.0);<br />

}<br />

[Action]<br />

static void ServerSend([Domain("Temperatures")] double datum) {}<br />

[Feature]<br />

static class TemperatureX4<br />

{<br />

readonly static Set Temperatures =<br />

new Set(98.8, 99.9, 100.0, 101.1);<br />

}<br />

[Action]<br />

static void ServerSend([Domain("Temperatures")] double datum) {}<br />

// Factory class, factory methods select features with different domains<br />

public static class Factory<br />

{<br />

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

{<br />

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

"ClientServer",<br />

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

}<br />

}<br />

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

{<br />

...<br />

}<br />

Figure 7.5. Client/server: model program with features that select domains (excerpts).<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!