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 200 | Next

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

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


144 Testing Closed Systems
// ... continued
case("ClientSocket"):
c.Socket(); return null;
case("ClientConnect"):
c.Connect(host,port); return null;
case("ClientSend"):
c.Send("T"); return null;
case("ClientReceive_Start"):
// c.Receive returns a double, not a string
return Action.Create("ClientReceive_Finish", c.Receive());
case("ClientClose"):
c.Close(); return null;
default: throw new Exception("Unexpected action " + action);
}
}
public void Reset()
{
s = new Server();
c = new Client();
}
// Factory method
public static IStepper Create()
{
return new Stepper();
}
}
}
Figure 8.5. Client/server: test harness (stepper) (2).
The DoAction method is the core of the test harness. It invokes the implementation??™s
controllable actions, monitors the implemenation??™s observable actions, collects
the output from the implementation, and checks the implementation against
the model.
To invoke each controllable action, the test runner passes DoAction a term that
represents the action. There is a case in DoAction for each action symbol. The code
in the case branch invokes the corresponding method in the implementation. In the
simple case where the action has no outputs, DoAction returns null.
Systems with Finite Models 145
Here is an example from Figure 8.4, the case where DoAction handles the server??™s
Bind action. Here the socket s and the host and port have been declared and assigned
in the stepper.


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