예제 #1
0
        public async Task GetReturnValue_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.GetReturnValue(elementObject, new XPathAttribute("//div"));

            Assert.Null(result);
        }
예제 #2
0
        public async Task GetReturnValue_returns_null_for_property_on_PageObject_marked_with_SelectorAttribute_when_Page_is_null()
        {
            var pageObject = new FakePageObject();
            var methodInfo = pageObject.GetType().GetProperty(nameof(FakePageObject.SelectorForElementHandle)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValue(pageObject, new SelectorAttribute(".retweets"));

            Assert.Null(result);
        }
예제 #3
0
        public async Task GetReturnValue_returns_null_for_property_on_PageObject_marked_with_XPathAttribute_but_wrong_return_type()
        {
            var pageObject = new FakePageObject();

            pageObject.Initialize(Page, null);
            var methodInfo = pageObject.GetType().GetProperty(nameof(FakePageObject.XPathForWrongReturnType)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValue(pageObject, new XPathAttribute("//div"));

            Assert.Null(result);
        }
예제 #4
0
        public async Task GetReturnValue_returns_ElementObject_array_for_property_on_PageObject_marked_with_XPathAttribute()
        {
            var pageObject = new FakePageObject();

            pageObject.Initialize(Page, null);
            var methodInfo = pageObject.GetType().GetProperty(nameof(FakePageObject.XPathForElementObjectArray)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValue(pageObject, new XPathAttribute("//div"));

            Assert.NotNull(result);
            Assert.IsAssignableFrom <FakeElementObject[]>(result);
        }
예제 #5
0
        public async Task GetReturnValue_returns_ElementHandle_array_for_property_on_PageObject_marked_with_SelectorAttribute()
        {
            var pageObject = new FakePageObject();

            pageObject.Initialize(Page, null);
            var methodInfo = pageObject.GetType().GetProperty(nameof(FakePageObject.SelectorForElementHandleArray)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            var result = await invocation.GetReturnValue(pageObject, new SelectorAttribute("div"));

            Assert.NotNull(result);
            Assert.IsType <ElementHandle[]>(result);
        }
예제 #6
0
        public async Task GetReturnValue_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.GetReturnValue(elementObject, new XPathAttribute("//div"));

            Assert.Null(result);
        }
예제 #7
0
        public async Task GetReturnValue_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.GetReturnValue(elementObject, new SelectorAttribute("div"));

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