using System;
using System.Collections.Generic;
using System.Text;
using TestScriptRunnerLib;
namespace Demo_CSharp_2005
{
class DemoTesterCreator : ITesterCreator1
{
}
}
using System;
using System.Collections.Generic;
using System.Text;
using TestScriptRunnerLib;
namespace Demo_CSharp_2005
{
class DemoTester : ITester2
{
private bool isAborted = false;
private ITrace myTrace = null;
}
}
public void Abort()
{
isAborted = true;
}
public uint ActionCount
{
get { return 4; }
}
public void ActionDocumentation(uint ActionNumber, out string Description, out Array inParameters, out Array outParameters)
{
switch (ActionNumber)
{
case 0: // pass
Description = "Always passes";
inParameters = null;
outParameters = null;
break;
case 1: // fail
Description = "Always fails";
inParameters = null;
outParameters = null;
break;
case 2: // random
Description = "Random pass/fail"
inParameters = new string[] { "int ratio" };
outParameters = null;
break;
case 3: // randomValue
Description = "Random value"
inParameters = new string[] { "int ratio" };
outParameters = new string[] { "int value" };
break;
default:
throw new Exception("Invalid action number " + ActionNumber);
}
}
public void ConstructorDocumentation(out string Description, out Array inParameters)
{
Description = "Creates a demo tester";
inParameters = null;
}
public string Description
{
get { return "This is a demo tester"; }
}
public bool Close()
{
return true;
}
public Result Execute(uint ActionNumber, Array parameters, out Array values)
{
values = null;
switch (ActionNumber)
{
case 0: //pass
return Result.TestPassed;
case 1: // fail
return Result.TestFailed;
case 2: // random
if (parameters.Length == 1)
{
int i = (int)parameters.GetValue(0);
if (i > 0)
{
Random r = new Random();
if (r.Next(i) != 0)
{
return Result.TestPassed;
}
}
Result.TestFailed;
}
throw new Exception("Invalid parameters to random action");
case 3: // randomValue
if (parameters.Length == 1)
{
int i = (int)parameters.GetValue(0);
if (i > 0)
{
Random r = new Random();
values = new object[] { r.Next(i) };
return Result.TestPassed;
}
}
throw new Exception("Invalid parameters to random action");
}
throw new Exception("Invalid ActionId");
}
public bool Open(Array parameters)
{
return true;
}
public void SetTrace(ITrace trace)
{
myTrace = trace;
}
public string Status
{
get { return ""; }
}
public string TesterType
{
get { return "demo"; }
}
public void scriptDirectory(script dir)
{
}
public string Version
{
get { return "2.0"; }
}
public string get_Actions(uint ActionNumber)
{
switch (ActionNumber)
{
case 0:
return "pass";
case 1:
return "fail";
case 2:
return "random";
case 3:
return "randomValue";
}
throw new Exception("Invalidaction number " + ActionNumber);
}
public uint NumberOfTypes
{
get { return 1; }
}
public string Version
{
get { "2.0"; }
}
public ITester create(uint TesterNumber)
{
switch (TesterNumber)
{
case 0:
return new DemoTester();
}
throw new Exception("Invalid tester number " + TesterNumber);
}
Demo_CSharp_2005.DemoTesterCreator.If you wish to debug your code add PluginRunner.exe as the external program in the Debug tab of the project properties and run it. Run a script that calls your tester and you should be able to add break points in the execute method.
If you wish to add logging information to your tester object you can call the log method of the ITrace object provided to your tester via the SetTrace method at any point. All logging entries from configuration to sever will be displayed in the logger view window and in the log file. If you wish to add debug log entries then use levels finest, finer and fine levels and change the logging level via the Logging->Set Logging Level option.
You can download the demo plug-in at DemoTester C# 2005.