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

Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte

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

Connect(new IPEndPoint(IPAddress.Parse(ipAddr), port));
}
public void Send(string command)
{
byte [] sendBuf = System.Text.Encoding.ASCII.GetBytes(command);
socket.Send(sendBuf);
}
public double Receive()
{
int nbytes = socket.Receive(receiveBuf);
string response =
System.Text.Encoding.ASCII.GetString(receiveBuf,0,nbytes);
return Double.Parse(response);
}
public void Close()
{
socket.Close();
}
public void Sleep(int seconds)
{
Thread.Sleep(1000*seconds); // convert seconds to milliseconds
}
}
}
Figure 2.5. Remote instrument client class.
20 Why We Need Model-Based Testing
namespace ClientServerImpl
{
// Temperature sensor simulator
public class Temperature
{
static int i = 0; // index for cycling through simulated data
static double[] temperature = { 71.2, 71.3, 71.4 }; // simulated data
// Simulate acquiring sample from sensor, substitute for real sensor
public double Sample()
{
return temperature[i++ % temperature.Length]; // cycle through data
}
public static double ConvertToCelsius(double temperature)
{
return 5*(temperature - 32.0)/9;
}
}
}
Figure 2.6. Remote instrument temperature sensor class.
Each of our source files begins with the namespace declaration:
namespace ClientServerImpl
Every class (or other type) has a fully qualified name formed from the simple
name that appears in its declaration and the namespace where it is declared.


Pages:
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6