SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 199 | Next

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

"Model-Based Software Testing and Analysis with C#"

The test
harness implements the modeling library??™s IStepper interface, so we often call a
test harness a stepper; it ???steps??? the implementation through the actions of each test
case. To implement the IStepper interface you must write two methods, Reset and
DoAction. The stepper must also provide a factory method that returns the stepper
object.
The Reset method executes after each test case to reset the implementation to its
initial state.
Systems with Finite Models 143
using System;
using NModel.Conformance;
using NModel.Terms;
namespace ClientServerImpl
{
public class Stepper: IStepper
{
const int port = 8000;
const string host = "127.0.0.1"; // localhost
Server s = new Server();
Client c = new Client();
public Action DoAction(Action action)
{
switch (action.Name)
{
case("Tests"): return null; // first action in test seq.
case("ServerSocket"):
s.Socket(); return null;
case("ServerBind"):
s.Bind(host,port); return null;
case("ServerListen"):
s.Listen(); return null;
case("ServerAccept"):
s.Accept(); return null;
case("ServerReceive"):
s.Receive(); return null;
case("ServerSend"):
// s.Send sends a double, not a string
s.Send((double)action[0]);
return null;
case("ServerCloseConnection"):
s.CloseConnection(); return null;
case("ServerClose"):
s.Close(); return null;
// continued ...
Figure 8.4. Client/server: test harness (stepper) (1).


Pages:
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6