本文整理汇总了C#中System.Collections.Generic.ConvertControlTypeToStringArray方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.ConvertControlTypeToStringArray方法的具体用法?C# System.Collections.Generic.ConvertControlTypeToStringArray怎么用?C# System.Collections.Generic.ConvertControlTypeToStringArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.ConvertControlTypeToStringArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestParametersAgainstCollection
private void TestParametersAgainstCollection(
ControlType controlType,
string name,
string automationId,
string className,
string txtValue,
IEnumerable<IUiElement> collection,
UsualWildcardRegex selector,
int expectedNumberOfElements)
{
// Arrange
ControlType[] controlTypes =
new[] { controlType };
GetControlCmdletBase cmdlet =
FakeFactory.Get_GetControlCmdletBase(controlTypes, name, automationId, className, txtValue);
var data =
new ControlSearcherData {
ControlType = controlTypes.ConvertControlTypeToStringArray(),
Name = name,
AutomationId = automationId,
Class = className,
Value = txtValue
};
Condition condition;
bool useWildcardOrRegex = true;
switch (selector) {
case UsualWildcardRegex.Wildcard:
condition =
ControlSearcher.GetWildcardSearchCondition(
data);
useWildcardOrRegex = true;
break;
case UsualWildcardRegex.Regex:
condition =
ControlSearcher.GetWildcardSearchCondition(
data);
useWildcardOrRegex = false;
break;
}
// Act
var resultList = RealCodeCaller.GetResultList_ReturnOnlyRightElements(collection.ToArray(), data, useWildcardOrRegex);
// Assert
MbUnit.Framework.Assert.Count(expectedNumberOfElements, resultList);
Assert.Equal(expectedNumberOfElements, resultList.Count);
string[] controlTypeNames;
switch (selector) {
case UsualWildcardRegex.Wildcard:
const WildcardOptions options = WildcardOptions.IgnoreCase;
// 20140312
// WildcardPattern namePattern = new WildcardPattern(name, options);
// WildcardPattern automationIdPattern = new WildcardPattern(automationId, options);
// WildcardPattern classNamePattern = new WildcardPattern(className, options);
// WildcardPattern txtValuePattern = new WildcardPattern(txtValue, options);
var namePattern = new WildcardPattern(name, options);
var automationIdPattern = new WildcardPattern(automationId, options);
var classNamePattern = new WildcardPattern(className, options);
var txtValuePattern = new WildcardPattern(txtValue, options);
// 20140312
// if (!string.IsNullOrEmpty(name)) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => namePattern.IsMatch(x.Current.Name));
// resultList.All(x => namePattern.IsMatch(x.Current.Name));
// }
// if (!string.IsNullOrEmpty(automationId)) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => automationIdPattern.IsMatch(x.Current.AutomationId));
// resultList.All(x => automationIdPattern.IsMatch(x.Current.AutomationId));
// }
// if (!string.IsNullOrEmpty(className)) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => classNamePattern.IsMatch(x.Current.ClassName));
// resultList.All(x => classNamePattern.IsMatch(x.Current.ClassName));
// }
// controlTypeNames =
// controlTypes.Select(ct => null != ct ? ct.ProgrammaticName.Substring(12) : string.Empty).ToArray();
// if (null != controlType) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => controlTypeNames.Contains(x.Current.ControlType.ProgrammaticName.Substring(12)));
// resultList.All(x => controlTypeNames.Contains(x.Current.ControlType.ProgrammaticName.Substring(12)));
// }
if (!string.IsNullOrEmpty(name)) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => namePattern.IsMatch(x.GetCurrent().Name));
resultList.All(x => namePattern.IsMatch(x.GetCurrent().Name));
}
if (!string.IsNullOrEmpty(automationId)) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => automationIdPattern.IsMatch(x.GetCurrent().AutomationId));
resultList.All(x => automationIdPattern.IsMatch(x.GetCurrent().AutomationId));
}
if (!string.IsNullOrEmpty(className)) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => classNamePattern.IsMatch(x.GetCurrent().ClassName));
resultList.All(x => classNamePattern.IsMatch(x.GetCurrent().ClassName));
}
controlTypeNames =
controlTypes.Select(ct => null != ct ? ct.ProgrammaticName.Substring(12) : string.Empty).ToArray();
if (null != controlType) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => controlTypeNames.Contains(x.GetCurrent().ControlType.ProgrammaticName.Substring(12)));
resultList.All(x => controlTypeNames.Contains(x.GetCurrent().ControlType.ProgrammaticName.Substring(12)));
}
//.........这里部分代码省略.........
示例2: TestParametersAgainstCollection
private void TestParametersAgainstCollection(
ControlType controlType,
string name,
string automationId,
string className,
string txtValue,
IEnumerable<IUiElement> collection,
int expectedNumberOfElements)
{
// Arrange
string controlTypeString = string.Empty;
if (null != controlType) {
controlTypeString = controlType.ProgrammaticName.Substring(12);
}
ControlType[] controlTypes =
new[] { controlType };
GetControlCmdletBase cmdlet =
FakeFactory.Get_GetControlCmdletBase(controlTypes, name, automationId, className, txtValue);
Condition condition =
ControlSearcher.GetExactSearchCondition(
new ControlSearcherData {
ControlType = controlTypes.ConvertControlTypeToStringArray(),
Name = name,
AutomationId = automationId,
Class = className,
Value = txtValue
});
IUiElement element =
FakeFactory.GetElement_ForFindAll(
collection,
condition);
// Act
var resultList = RealCodeCaller.GetResultList_ExactSearch(element, condition, cmdlet.SearchCriteria);
// Assert
MbUnit.Framework.Assert.Count(expectedNumberOfElements, resultList);
Assert.Equal(expectedNumberOfElements, resultList.Count);
// 20140312
// if (!string.IsNullOrEmpty(name)) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.Current.Name == name);
// resultList.All(x => x.Current.Name == name);
// }
// if (!string.IsNullOrEmpty(automationId)) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.Current.AutomationId == automationId);
// resultList.All(x => x.Current.AutomationId == automationId);
// }
// if (!string.IsNullOrEmpty(className)) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.Current.ClassName == className);
// resultList.All(x => x.Current.ClassName == className);
// }
// if (null != controlType) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.Current.ControlType == controlType);
// resultList.All(x => x.Current.ControlType == controlType);
// }
if (!string.IsNullOrEmpty(name)) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.GetCurrent().Name == name);
resultList.All(x => x.GetCurrent().Name == name);
}
if (!string.IsNullOrEmpty(automationId)) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.GetCurrent().AutomationId == automationId);
resultList.All(x => x.GetCurrent().AutomationId == automationId);
}
if (!string.IsNullOrEmpty(className)) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.GetCurrent().ClassName == className);
resultList.All(x => x.GetCurrent().ClassName == className);
}
if (null != controlType) {
MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.GetCurrent().ControlType == controlType);
resultList.All(x => x.GetCurrent().ControlType == controlType);
}
if (string.IsNullOrEmpty(txtValue)) return;
MbUnit.Framework.Assert.ForAll(
resultList
.Cast<IUiElement>()
.ToList<IUiElement>(), x =>
{
IValuePattern valuePattern = x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern;
return valuePattern != null && valuePattern.Current.Value == txtValue;
});
resultList.All(
x => {
IValuePattern valuePattern = x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern;
return valuePattern != null && valuePattern.Current.Value == txtValue;
});
/*
if (!string.IsNullOrEmpty(txtValue)) {
MbUnit.Framework.Assert.ForAll(
resultList
.Cast<IUiElement>()
.ToList<IUiElement>(), x =>
{
// 20131208
// IValuePattern valuePattern = x.GetCurrentPattern(ValuePattern.Pattern) as IValuePattern;
// IValuePattern valuePattern = x.GetCurrentPattern<IValuePattern, ValuePattern>(ValuePattern.Pattern) as IValuePattern;
IValuePattern valuePattern = x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern;
//.........这里部分代码省略.........