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


C# Element.Ancestor方法代码示例

本文整理汇总了C#中Element.Ancestor方法的典型用法代码示例。如果您正苦于以下问题:C# Element.Ancestor方法的具体用法?C# Element.Ancestor怎么用?C# Element.Ancestor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Element的用法示例。


在下文中一共展示了Element.Ancestor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AncestorGenericType

        public void AncestorGenericType()
        {
            var nativeElementMock = new Mock<INativeElement>();
            var firstParentDivMock = new Mock<INativeElement>();
            var secondParentDivMock = new Mock<INativeElement>();
            var domContainerMock = new Mock<DomContainer>(new object[] { });

            element = new Element(domContainerMock.Object, nativeElementMock.Object);
            nativeElementMock.Expect(native => native.Parent).Returns(firstParentDivMock.Object);

            firstParentDivMock.Expect(first => first.TagName).Returns("a");
            firstParentDivMock.Expect(first => first.Parent).Returns(secondParentDivMock.Object);

            secondParentDivMock.Expect(second => second.TagName).Returns("div");

            Assert.That(element.Ancestor<Div>(), Is.Not.Null);

            nativeElementMock.VerifyAll();
            firstParentDivMock.VerifyAll();
            secondParentDivMock.VerifyAll();
            domContainerMock.VerifyAll();
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:22,代码来源:ElementTests.cs

示例2: AncestorTypeShouldOnlyExceptTypesInheritingElement

        public void AncestorTypeShouldOnlyExceptTypesInheritingElement()
        {
            // GIVEN
            var nativeElementMock = new Mock<INativeElement>();
            nativeElementMock.Expect(x => x.IsElementReferenceStillValid()).Returns(true);
            var element1 = new Element(new Mock<DomContainer>().Object, nativeElementMock.Object);

            // WHEN
            element1.Ancestor(typeof (String));

            // THEN exception
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:12,代码来源:ElementTests.cs

示例3: AncestorTagNameAndAttributeConstraintShouldReturnTypedElement

        public void AncestorTagNameAndAttributeConstraintShouldReturnTypedElement()
        {
            // GIVEN
            var nativeElementMock = new Mock<INativeElement>();
            var firstParentDivMock = new Mock<INativeElement>();
            var secondParentDivMock = new Mock<INativeElement>();
            var domContainerMock = new Mock<DomContainer> (new object[] { });

            element = new Element(domContainerMock.Object, nativeElementMock.Object);

            nativeElementMock.Expect(native => native.Parent).Returns(firstParentDivMock.Object);

            firstParentDivMock.Expect(first => first.TagName).Returns("div");
            firstParentDivMock.Expect(first => first.GetAttributeValue("tagName")).Returns("div");
            firstParentDivMock.Expect(first => first.GetAttributeValue("innertext")).Returns("first ancestor");

            firstParentDivMock.Expect(first => first.Parent).Returns(secondParentDivMock.Object);

            secondParentDivMock.Expect(second => second.TagName).Returns("div");
            secondParentDivMock.Expect(second => second.GetAttributeValue("tagName")).Returns("div");
            secondParentDivMock.Expect(second => second.GetAttributeValue("innertext")).Returns("second ancestor");

            // WHEN
            var ancestor = element.Ancestor("Div", Find.ByText("second ancestor"));

            // THEN
            nativeElementMock.VerifyAll();
            firstParentDivMock.VerifyAll();
            secondParentDivMock.VerifyAll();

            Assert.IsInstanceOfType(typeof (Div), ancestor);
            Assert.That(ancestor.Text, Is.EqualTo("second ancestor"));
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:33,代码来源:ElementTests.cs


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