当前位置: 首页>>代码示例>>C#>>正文


C# Constraints.ConstraintContext类代码示例

本文整理汇总了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);
		}
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:ComponentConstraint.cs

示例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);
		}
开发者ID:modulexcite,项目名称:FluentSharp_Fork.WatiN,代码行数:9,代码来源:ElementConstraint.cs

示例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));
        }
开发者ID:fschwiet,项目名称:watin_unbranched,代码行数:13,代码来源:NotConstraintTests.cs

示例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);
        }
开发者ID:fschwiet,项目名称:watin_unbranched,代码行数:14,代码来源:NotConstraintTests.cs

示例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;
        }
开发者ID:modulexcite,项目名称:FluentSharp_Fork.WatiN,代码行数:14,代码来源:AttachToIeHelper.cs

示例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);
        }
开发者ID:kevinswarner,项目名称:Hover_OLD,代码行数:16,代码来源:LabelTextConstraint.cs

示例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();
            }
        }
开发者ID:modulexcite,项目名称:FluentSharp_Fork.WatiN,代码行数:24,代码来源:Constraint.cs

示例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();
        }
开发者ID:kumichou,项目名称:WatiN_FindByCssSelector,代码行数:20,代码来源:FindByMultipleAttributeConstraintsTests.cs

示例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();
        }
开发者ID:kumichou,项目名称:WatiN_FindByCssSelector,代码行数:26,代码来源:FindByMultipleAttributeConstraintsTests.cs

示例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));
        }
开发者ID:kumichou,项目名称:WatiN_FindByCssSelector,代码行数:13,代码来源:FindByMultipleAttributeConstraintsTests.cs

示例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));
 }
开发者ID:kumichou,项目名称:WatiN_FindByCssSelector,代码行数:7,代码来源:FindByMultipleAttributeConstraintsTests.cs

示例12: MatchesImpl

 /// <inheritdoc />
 public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
 {
     var attributeValue = attributeBag.GetAttributeValue(attributeName);
     return comparer.Compare(attributeValue);
 }
开发者ID:modulexcite,项目名称:FluentSharp_Fork.WatiN,代码行数:6,代码来源:AttributeConstraint.cs

示例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));
        }
开发者ID:kumichou,项目名称:WatiN_FindByCssSelector,代码行数:12,代码来源:FindByMultipleAttributeConstraintsTests.cs

示例14: MatchesImpl

 protected override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
 {
     var element = attributeBag.GetAdapter<Element>();
     return element != null && Comparer.Compare(IsVisible(element).ToString());
 }
开发者ID:fschwiet,项目名称:watin_unbranched,代码行数:5,代码来源:ModalPopupExtenderTests.cs

示例15: MatchesImpl

 /// <inheritdoc />
 public override bool MatchesImpl(IAttributeBag attributeBag, ConstraintContext context)
 {
     return false;
 }
开发者ID:modulexcite,项目名称:FluentSharp_Fork.WatiN,代码行数:5,代码来源:NoneConstraint.cs


注:本文中的WatiN.Core.Constraints.ConstraintContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。