本文整理汇总了C#中WatiN.Core.Constraints.ConstraintContext类的典型用法代码示例。如果您正苦于以下问题:C# ConstraintContext类的具体用法?C# ConstraintContext怎么用?C# ConstraintContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstraintContext类属于WatiN.Core.Constraints命名空间,在下文中一共展示了ConstraintContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchesImpl
/// <inheritdoc />
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
{
Component component = attributeBag.GetAdapter<Component>();
if (component == null)
throw new WatiNException("This constraint class can only be used to compare against a component");
return comparer.Compare(component);
}
示例2: MatchesImpl
/// <inheritdoc />
public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
{
Element element = attributeBag.GetAdapter<Element>();
if (element == null)
throw new WatiNException("This constraint class can only be used to compare against an element");
return comparer.Compare(element);
}
示例3: AttributeOperatorNotOverload
public void AttributeOperatorNotOverload()
{
// Given
var mockAttributeBag = new Mock<IAttributeBag>().Object;
ConstraintContext context = new ConstraintContext();
// WHEN
var attributenot = !Find.Any;
// THEN
Assert.IsInstanceOfType(typeof (NotConstraint), attributenot, "Expected NotAttributeConstraint instance");
Assert.IsFalse(attributenot.Matches(mockAttributeBag, context));
}
示例4: NotTest
public void NotTest()
{
// Given
var mockAttributeBag = new Mock<IAttributeBag>().Object;
ConstraintContext context = new ConstraintContext();
var notConstraint = new NotConstraint(Find.None);
// WHEN
var result = notConstraint.Matches(mockAttributeBag, context);
// THEN
Assert.That(result, Is.True);
}
示例5: FindIEPartiallyInitialized
public IE FindIEPartiallyInitialized(Constraint findBy)
{
var allBrowsers = new ShellWindows2();
var context = new ConstraintContext();
foreach (IWebBrowser2 browser in allBrowsers)
{
var ie = CreateBrowserInstance(new IEBrowser(browser));
if (ie.Matches(findBy, context))
return ie;
}
return null;
}
示例6: MatchesImpl
/// <inheritdoc />
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
{
var element = attributeBag.GetAdapter<Element>();
if (element == null)
throw new WatiNException("This constraint class can only be used to compare against an element");
var cache = (LabelCache)context.GetData(this);
if (cache == null)
{
cache = new LabelCache(labelText);
context.SetData(this, cache);
}
return cache.IsMatch(element);
}
示例7: Matches
/// <summary>
/// Returns true if the constraint matches an object described by an attribute bag.
/// </summary>
/// <param name="attributeBag">The attribute bag</param>
/// <param name="context">The constraint matching context</param>
/// <returns>True if the constraint matches</returns>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="attributeBag"/> or <paramref name="context"/> is null</exception>
public bool Matches(IAttributeBag attributeBag, ConstraintContext context)
{
if (attributeBag == null)
throw new ArgumentNullException("attributeBag");
if (context == null)
throw new ArgumentNullException("context");
try
{
EnterMatch();
return MatchesImpl(attributeBag, context);
}
finally
{
ExitMatch();
}
}
示例8: RecusiveCallExceptionExpected
public void RecusiveCallExceptionExpected()
{
var mockAttributeBag = new Mock<IAttributeBag>();
// Note: Creating a re-entrant constraint is now much more difficult than
// before because constraints are immutable. Even the code findBy |= findBy
// will not create a re-entrant constraint, it will just be an Or constraint
// with two identical clauses. Given this change in constraint construction
// we should consider removing the re-entrance checks in the future. -- Jeff.
Constraint findBy = Find.By("tag", "value");
findBy |= new PredicateConstraint<IAttributeBag>(bag => findBy.Matches(bag, new ConstraintContext()));
ConstraintContext context = new ConstraintContext();
mockAttributeBag.Expect(bag => bag.GetAttributeValue("tag")).Returns("val");
mockAttributeBag.Expect(bag => bag.GetAdapter<IAttributeBag>()).Returns(mockAttributeBag.Object);
findBy.Matches(mockAttributeBag.Object, context);
mockAttributeBag.VerifyAll();
}
示例9: TrueAndIndexConstraintAndTrue
public void TrueAndIndexConstraintAndTrue()
{
var mockAttributeBag = new Mock<IAttributeBag>();
var findBy = Find.ByName("Z").And(new IndexConstraint(1)).And(Find.ByValue("text"));
ConstraintContext context = new ConstraintContext();
mockAttributeBag.Expect(bag => bag.GetAttributeValue("name")).Returns("Z");
Assert.IsFalse(findBy.Matches(mockAttributeBag.Object, context), "False because index will be 0 when evaluated.");
mockAttributeBag.Expect(bag => bag.GetAttributeValue("name")).Returns("Y");
Assert.IsFalse(findBy.Matches(mockAttributeBag.Object, context), "False because index will be skipped since first clause fails to match.");
mockAttributeBag.Expect(bag => bag.GetAttributeValue("name")).Returns("Z");
mockAttributeBag.Expect(bag => bag.GetAttributeValue("value")).Returns("text");
Assert.IsTrue(findBy.Matches(mockAttributeBag.Object, context), "True because index will be 1 when evaluated.");
mockAttributeBag.Expect(bag => bag.GetAttributeValue("name")).Returns("Z");
Assert.IsFalse(findBy.Matches(mockAttributeBag.Object, context), "False because index will be 2 when evaluated.");
mockAttributeBag.VerifyAll();
}
示例10: OccurenceOr
public void OccurenceOr()
{
var findBy = new IndexConstraint(2).Or(Find.ByName("Z"));
ConstraintContext context = new ConstraintContext();
var mockAttributeBag = new MockAttributeBag("name", "Z");
Assert.IsTrue(findBy.Matches(mockAttributeBag, context));
mockAttributeBag = new MockAttributeBag("name", "y");
Assert.IsFalse(findBy.Matches(mockAttributeBag, context));
Assert.IsTrue(findBy.Matches(mockAttributeBag, context));
}
示例11: OrSecondTrue
public void OrSecondTrue()
{
var findBy = Find.ByName("X").Or(Find.ByName("Y"));
var mockAttributeBag = new MockAttributeBag("name", "Y");
ConstraintContext context = new ConstraintContext();
Assert.IsTrue(findBy.Matches(mockAttributeBag, context));
}
示例12: MatchesImpl
/// <inheritdoc />
public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
{
var attributeValue = attributeBag.GetAttributeValue(attributeName);
return comparer.Compare(attributeValue);
}
示例13: Occurence2
public void Occurence2()
{
Constraint findBy = new IndexConstraint(2);
var mockAttributeBag = new MockAttributeBag("name", "Z");
ConstraintContext context = new ConstraintContext();
Assert.IsFalse(findBy.Matches(mockAttributeBag, context));
Assert.IsFalse(findBy.Matches(mockAttributeBag, context));
Assert.IsTrue(findBy.Matches(mockAttributeBag, context));
Assert.IsFalse(findBy.Matches(mockAttributeBag, context));
}
示例14: MatchesImpl
protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
{
var element = attributeBag.GetAdapter<Element>();
return element != null && Comparer.Compare(IsVisible(element).ToString());
}
示例15: MatchesImpl
/// <inheritdoc />
public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
{
return false;
}