Created
October 22, 2013 16:07
-
-
Save kberridge/7103428 to your computer and use it in GitHub Desktop.
Coypu HasValue extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool HasValue(this ElementScope scope, string text, Options options = null) | |
{ | |
var f = scope.GetType().GetField("options", BindingFlags.Instance | BindingFlags.NonPublic); | |
var config = (Options)f.GetValue(scope); | |
var robustly = new RetryUntilTimeoutRobustWrapper(); | |
return robustly.Robustly(new HasValueQuery(scope, text, options ?? config)); | |
} | |
class HasValueQuery : Query<bool> | |
{ | |
protected readonly Options options; | |
protected readonly string value; | |
protected ElementScope Scope { get; private set; } | |
public TimeSpan Timeout { get; private set; } | |
public TimeSpan RetryInterval { get; private set; } | |
public HasValueQuery(ElementScope scope, string value, Options options) | |
{ | |
this.options = options; | |
this.value = value; | |
Scope = scope; | |
Timeout = options.Timeout; | |
RetryInterval = options.RetryInterval; | |
} | |
public bool Run() | |
{ | |
return Scope.Now().Value == value; | |
} | |
public bool ExpectedResult { get { return true; } } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment