當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。