2016-01-18 12 views

ответ

1

Вы можете добавить любое другое пользовательское утверждение, которое вы хотите, настроив код. Выполните следующие шаги:

Сначала Добавьте любое утверждение в свое свойство и сгенерируйте код для метода проверки.

Переместить метод проверки на UIMap.cs из UIMap.Designer.cs

Теперь Настройка кода в UIMap.cs в методе валидации. Вот пример:

/// <summary> 
/// Verifies that the result count is > the min value passed. 
/// </summary> 
public void VerifyMinimumResultCount(int minResultCount) 
{ 
    HtmlSpan totalResults = 
     this.ApplicationWindow. 
     IntermediateParent.TotalResultsTextBox; 

    // Use regular expression to get the text out of the 
    // Control Property. 
    int actualResultCount; 
    Match resultPattern = Regex.Match(totalResults.Text, 
     "[0-9]+-[0-9]+ of ([0-9,]*) results"); 
    Assert.IsTrue(resultPattern.Success, 
     "Regular expression match failed"); 
    Assert.IsTrue(int.TryParse(resultPattern.Groups[1].Value, 
        NumberStyles.Number, 
        CultureInfo.CurrentCulture, 
        out actualResultCount), 
        "Parsing failed"); 
    Assert.IsTrue(actualResultCount >= minResultCount, 
      "Got less than expected min result"); 
} 

Или вы можете использовать AssertTrue:

//... 
int expectedValueLimit = 2; 
int actualValue = int.Parse(myUiControl.text); 
Assert.IsTrue((actualValue > expectedValueLimit), "myUiControl value is less than " + expectedValueLimit); 
//... 

Источник: https://social.msdn.microsoft.com/Forums/en-US/da835e54-598b-4f3d-a5bf-6c4d1ea32de6/codedui-greater-than-assertion?forum=vsautotest

Смежные вопросы