本文整理汇总了C#中Context.ReadConfigAsBool方法的典型用法代码示例。如果您正苦于以下问题:C# Context.ReadConfigAsBool方法的具体用法?C# Context.ReadConfigAsBool怎么用?C# Context.ReadConfigAsBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.ReadConfigAsBool方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteValidation
/// <summary>
/// IValidationStep.ExecuteValidation() implementation
/// </summary>
/// <param name='data'>The stream cintaining the data to be validated.</param>
/// <param name='validatorConfig'>The Xml fragment containing the configuration for the test step</param>
/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
public void ExecuteValidation(Stream data, XmlNode validatorConfig, Context context)
{
_comparisonDataPath = context.ReadConfigAsString( validatorConfig, "ComparisonDataPath" );
_compareAsUtf8 = context.ReadConfigAsBool( validatorConfig, "CompareAsUTF8", true);
ExecuteValidation(data, context);
}
示例2: Execute
/// <summary>
/// ITestStep.Execute() implementation
/// </summary>
/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
public void Execute(XmlNode testConfig, Context context)
{
XmlNodeList queues = testConfig.SelectNodes( "*" );
foreach( XmlNode queue in queues)
{
string queuePath = queue.InnerText;
bool transactional = context.ReadConfigAsBool(testConfig, "QueuePath/@transactional");
MessageQueue.Create(queuePath, transactional);
context.LogInfo( "The queue: \"{0}\" was created successfully.", queuePath );
}
}
示例3: Execute
/// <summary>
/// ITestStep.Execute() implementation
/// </summary>
/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
public void Execute(XmlNode testConfig, Context context)
{
_delayBeforeCheck = context.ReadConfigAsInt32( testConfig, "DelayBeforeCheck" );
_connectionString = context.ReadConfigAsString( testConfig, "ConnectionString" );
var queryConfig = testConfig.SelectSingleNode( "SQLQuery" );
_sqlQuery = SqlQuery.BuildSQLQuery(queryConfig, context);
_numberOfRowsExpected = context.ReadConfigAsInt32(testConfig, "NumberOfRowsExpected", true);
var rowCollection = testConfig.SelectSingleNode("Rows");
var bamValidationRows = rowCollection.SelectNodes("*");
foreach (XmlNode bamValidationRow in bamValidationRows)
{
var drtv = new DBRowToValidate();
var bamValidationCols = bamValidationRow.SelectNodes("*");
foreach (XmlNode bamValidationCol in bamValidationCols)
{
bool isUnique = context.ReadConfigAsBool(bamValidationCol, "@isUnique", true);
string colName = bamValidationCol.LocalName;
string colValue = bamValidationCol.InnerText;
var dctv = new DBCellToValidate(colName, colValue);
if (isUnique)
{
drtv.AddUniqueCell(dctv);
}
else
{
drtv.AddCell(dctv);
}
}
_dbRowsToValidate.AddRow(drtv);
}
Execute(context);
}
示例4: Execute
/// <summary>
/// ITestStep.Execute() implementation
/// </summary>
/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
public void Execute(XmlNode testConfig, Context context)
{
_directory = context.ReadConfigAsString(testConfig, "Directory");
_searchPattern = context.ReadConfigAsString(testConfig, "SearchPattern");
_deleteFile = context.ReadConfigAsBool(testConfig, "DeleteFile");
_timeout = context.ReadConfigAsDouble(testConfig, "Timeout");
_validationConfig = testConfig.SelectSingleNode("ValidationStep");
_contextConfig = testConfig.SelectSingleNode("ContextLoaderStep");
Execute(context);
}
示例5: Execute
/// <summary>
/// Execute() implementation
/// </summary>
/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
public void Execute(XmlNode testConfig, Context context)
{
int delayBeforeCheck = context.ReadConfigAsInt32(testConfig, "DelayBeforeCheck", true);
string server = context.ReadConfigAsString(testConfig, "Server");
string user = context.ReadConfigAsString(testConfig, "User");
string password = context.ReadConfigAsString(testConfig, "Password");
string from = null;
bool showBody = false;
string subject = null;
int attachments = -1;
bool found = false;
if (testConfig.SelectSingleNode("ShowBody") != null)
{
showBody = context.ReadConfigAsBool(testConfig, "ShowBody");
}
if (testConfig.SelectSingleNode("From") != null)
{
from = context.ReadConfigAsString(testConfig, "From");
}
if (testConfig.SelectSingleNode("Subject") != null)
{
subject = context.ReadConfigAsString(testConfig, "Subject");
}
if (testConfig.SelectSingleNode("Attachments") != null)
{
attachments = context.ReadConfigAsInt32(testConfig, "Attachments");
}
if ( delayBeforeCheck > 0 )
{
context.LogInfo("Waiting for {0} seconds before checking the mail.", delayBeforeCheck);
System.Threading.Thread.Sleep(delayBeforeCheck*1000);
}
var email = new Pop3Client(user, password, server);
email.OpenInbox();
try
{
while( email.NextEmail())
{
if (email.To == user && (email.From == from || from == null) && (email.Subject == subject || subject == null))
{
if (attachments > 0 && email.IsMultipart)
{
int a = 0;
IEnumerator enumerator = email.MultipartEnumerator;
while(enumerator.MoveNext())
{
var multipart = (Pop3Component)
enumerator.Current;
if( multipart.IsBody )
{
if (showBody)
{
context.LogData("Multipart body", multipart.Data);
}
}
else
{
context.LogData("Attachment name", multipart.Name);
a++;
}
}
if (attachments == a)
{
found = true;
break;
}
}
else
{
if (showBody)
{
context.LogData("Single body", email.Body);
}
found = true;
break;
}
}
}
if (!found)
{
throw new Exception("Failed to find email message");
}
else
{
email.DeleteEmail();
}
//.........这里部分代码省略.........
示例6: Execute
/// <summary>
/// ITestStep.Execute() implementation
/// </summary>
/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
public void Execute(XmlNode testConfig, Context context)
{
int delayBeforeCheck = context.ReadConfigAsInt32( testConfig, "DelayBeforeCheck" );
string connectionString = context.ReadConfigAsString( testConfig, "ConnectionString" );
string rootElement = context.ReadConfigAsString( testConfig, "RootElement" );
bool allowEmpty = context.ReadConfigAsBool ( testConfig, "AllowEmpty" );
XmlNode queryConfig = testConfig.SelectSingleNode( "SQLQuery" );
string sqlQuery = BuildSqlQuery( queryConfig, context );
XmlNode validationConfig = testConfig.SelectSingleNode("ValidationStep");
XmlNode contextConfig = testConfig.SelectSingleNode("ContextLoaderStep");
context.LogInfo("Using database connection string: {0}", connectionString);
context.LogInfo("Executing database query : {0}", sqlQuery );
// Sleep for delay seconds...
System.Threading.Thread.Sleep(delayBeforeCheck*1000);
string xml = GetXmlData(connectionString, sqlQuery);
context.LogInfo("Xml returned : {0}", xml );
if(xml != null && xml.Trim().Length > 0)
{
//prepare to execute context loader
byte [] buffer = System.Text.Encoding.ASCII.GetBytes("<" + rootElement +">" + xml + "</" + rootElement + ">");
MemoryStream data = null;
try
{
data = new MemoryStream(buffer);
data.Seek(0, SeekOrigin.Begin);
context.ExecuteContextLoader( data, contextConfig );
data.Seek(0, SeekOrigin.Begin);
context.ExecuteValidator( data, validationConfig );
}
finally
{
if ( null != data )
{
data.Close();
}
}
}
else if (!allowEmpty && (xml == null || xml.Trim().Length > 0))
{
throw new Exception("Response was expected.No Xml returned.");
}
else if (allowEmpty)
{
context.LogWarning("No Xml was returned from the DB Query. AllowEmpty has been set to true and hence no error has been raised");
}
}
示例7: Execute
/// <summary>
/// ITestStep.Execute() implementation
/// </summary>
/// <param name='testConfig'>The Xml fragment containing the configuration for this test step</param>
/// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
public void Execute(XmlNode testConfig, Context context)
{
_delayBeforeCheck = context.ReadConfigAsInt32(testConfig, "DelayBeforeCheck", true);
_machine = context.ReadConfigAsString(testConfig, "Machine", true);
_eventId = context.ReadConfigAsInt32(testConfig, "EventId", true);
_eventLog = context.ReadConfigAsString(testConfig, "EventLog");
_source = context.ReadConfigAsString(testConfig, "Source");
_type = context.ReadConfigAsString(testConfig, "Type");
_failIfFound = context.ReadConfigAsBool(testConfig, "FailIfFound", true);
_entryType = (EventLogEntryType)Enum.Parse(typeof(EventLogEntryType), _type, true);
XmlNodeList validationNodes = testConfig.SelectNodes("ValidationRegex");
if (string.IsNullOrEmpty(_machine))
{
_machine = Environment.MachineName;
}
if (null != validationNodes)
{
foreach (XmlNode validationNode in validationNodes)
{
_validationRegexs.Add(validationNode.InnerText);
}
}
Execute(context);
}