public async Task GetReturnValueAsync_returns_null_for_property_on_ElementObject_marked_with_XPathAttribute_when_Page_is_null()
        {
            var elementObject = new FakeElementObject();
            var methodInfo    = elementObject.GetType().GetProperty(nameof(FakeElementObject.XPathForElementHandleArray)).GetMethod;
            var invocation    = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValueAsync(elementObject, new XPathAttribute("//div"));

            Assert.Null(result);
        }
예제 #2
0
        protected override async Task SetUp()
        {
            await Page.SetContentAsync(Fake.Html);

            _subject    = new XPathInterceptor();
            _pageObject = new FakePageObject();
            _pageObject.Initialize(Page, null);
            _elementObject = new FakeElementObject();
            _elementObject.Initialize(Page, await Page.QuerySelectorAsync("html"));
        }
예제 #3
0
        public async Task GetReturnValue_returns_null_for_property_on_ElementObject_marked_with_SelectorAttribute_when_Page_is_null()
        {
            var elementObject = new FakeElementObject();
            var methodInfo    = elementObject.GetType().GetProperty(nameof(FakeElementObject.SelectorForElementHandle)).GetMethod;
            var invocation    = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValue(elementObject, new SelectorAttribute(".tweet"));

            Assert.Null(result);
        }
        public async Task GetReturnValueAsync_returns_null_for_property_on_ElementObject_marked_with_XPathAttribute_but_wrong_return_type()
        {
            var elementHandle = await Page.QuerySelectorAsync("html");

            var elementObject = new FakeElementObject();

            elementObject.Initialize(Page, elementHandle);
            var methodInfo = elementObject.GetType().GetProperty(nameof(FakeElementObject.XPathForWrongReturnType)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValueAsync(elementObject, new XPathAttribute("//div"));

            Assert.Null(result);
        }
        public async Task GetReturnValueAsync_returns_ElementObject_array_for_property_on_ElementObject_marked_with_SelectorAttribute()
        {
            var elementHandle = await Page.QuerySelectorAsync("html");

            var elementObject = new FakeElementObject();

            elementObject.Initialize(Page, elementHandle);
            var methodInfo = elementObject.GetType().GetProperty(nameof(FakeElementObject.SelectorForElementObjectArray)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValueAsync(elementObject, new SelectorAttribute("div"));

            Assert.NotNull(result);
            Assert.IsAssignableFrom <FakeElementObject[]>(result);
        }