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.

Systems with Finite <strong>Model</strong>s 119<br />

namespace ClientServer<br />

{<br />

...<br />

static class ClientServer<br />

{<br />

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

internal static Socket serverSocket = Socket.None;<br />

...<br />

}<br />

}<br />

[Feature]<br />

static class Server<br />

{<br />

// Server action methods and enabling conditions<br />

...<br />

public static bool ServerSocketEnabled()<br />

...<br />

[Action]<br />

public static void ServerSocket()<br />

...<br />

}<br />

[Feature]<br />

class Client<br />

{<br />

// Client action methods and enabling conditions<br />

...<br />

}<br />

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

public static class Factory<br />

{<br />

// No features argument in constructor, include all features<br />

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

{<br />

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

"ClientServer");<br />

}<br />

}<br />

// Features argument in constructor, include just that feature<br />

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

{<br />

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

"ClientServer",<br />

new Set("Server")); //feature<br />

}<br />

Figure 7.3. Client/server: model program with features (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!