public void IsGetterPropertyWithAttribute_returns_false_for_invocation_of_non_getter_property()
        {
            var methodInfo = typeof(string).GetMethod(nameof(string.GetTypeCode));
            var invocation = new FakeInvocation(methodInfo);

            Assert.False(invocation.IsGetterPropertyWithAttribute <SelectorAttribute>());
        }
        public void IsGetterPropertyWithAttribute_returns_true_for_invocation_of_getter_property_marked_with_given_attribute()
        {
            var methodInfo = typeof(FakePageObject).GetProperty(nameof(FakePageObject.SelectorForElementHandle)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            Assert.True(invocation.IsGetterPropertyWithAttribute <SelectorAttribute>());
        }
        public void GetAttribute_returns_the_given_attribute()
        {
            var methodInfo = typeof(FakePageObject).GetProperty(nameof(FakePageObject.SelectorForElementHandle)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            Assert.NotNull(invocation.GetAttribute <SelectorAttribute>());
        }
        public void HasValidReturnType_returns_false_for_invocation_that_does_not_return_Task_of_T()
        {
            var methodInfo = typeof(FakePageObject).GetProperty(nameof(FakePageObject.SelectorForNonTaskReturnType)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            Assert.False(invocation.HasValidReturnType());
        }
        public void IsReturning_returns_false_for_invocation_of_method_that_does_not_return_Task_of_given_type()
        {
            var methodInfo = typeof(FakePageObject).GetProperty(nameof(FakePageObject.SelectorForNonTaskReturnType)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            Assert.False(invocation.IsReturning <ElementHandle>());
        }
        public void HasValidReturnType_returns_true_for_invocation_that_return_Task_of_T()
        {
            var methodInfo = typeof(FakePageObject).GetProperty(nameof(FakePageObject.SelectorForElementHandle)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            Assert.True(invocation.HasValidReturnType());
        }
        public void IsReturningElementObjectArray_returns_true_for_invocation_of_method_that_returns_Task_of_ElementObject_subclass_array()
        {
            var methodInfo = typeof(FakePageObject).GetProperty(nameof(FakePageObject.SelectorForElementObjectArray)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            Assert.True(invocation.IsReturningElementObjectArray());
        }
        public void IsReturningElementObject_returns_false_for_invocation_of_method_that_does_not_return_Task_of_ElementObject_subclass()
        {
            var methodInfo = typeof(FakePageObject).GetProperty(nameof(FakePageObject.SelectorForElementObjectWithNonTaskReturnType)).GetMethod;
            var invocation = new FakeInvocation(methodInfo);

            Assert.False(invocation.IsReturningElementObject());
        }
Пример #9
0
        public void Intercept_sets_the_ReturnValue_to_null_for_property_on_ElementObject_marked_with_XPathAttribute_but_non_Task_return_type()
        {
            var methodInfo = _elementObject.GetType().GetProperty(nameof(FakeElementObject.XPathForNonTaskReturnType)).GetMethod;
            var invocation = new FakeInvocation(methodInfo, _elementObject);

            _subject.Intercept(invocation);

            Assert.Null(invocation.ReturnValue);
        }
Пример #10
0
        public void Intercept_sets_the_ReturnValue_to_null_for_property_on_PageObject_marked_with_XPathAttribute_but_wrong_return_type()
        {
            var methodInfo = _pageObject.GetType().GetProperty(nameof(FakePageObject.XPathForWrongReturnType)).GetMethod;
            var invocation = new FakeInvocation(methodInfo, _pageObject);

            _subject.Intercept(invocation);

            Assert.Null(invocation.ReturnValue);
        }
        public async Task GetReturnValueAsync_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.GetReturnValueAsync(pageObject, new SelectorAttribute(".retweets"));

            Assert.Null(result);
        }
Пример #12
0
        public void Intercept_sets_the_ReturnValue_to_null_for_property_on_unknown_object_marked_with_XPathAttribute()
        {
            var objectWithNoBaseClass = new FakeObjectWithNoBaseClass();
            var methodInfo            = objectWithNoBaseClass.GetType().GetProperty(nameof(FakeObjectWithNoBaseClass.XPathForElementHandleArray)).GetMethod;
            var invocation            = new FakeInvocation(methodInfo, objectWithNoBaseClass);

            _subject.Intercept(invocation);

            Assert.Null(invocation.ReturnValue);
        }
        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);
        }
Пример #14
0
        public async Task Intercept_sets_the_ReturnValue_to_Task_of_ElementHandle_array_for_property_on_ElementObject_marked_with_XPathAttribute()
        {
            var methodInfo = _elementObject.GetType().GetProperty(nameof(FakeElementObject.XPathForElementHandleArray)).GetMethod;
            var invocation = new FakeInvocation(methodInfo, _elementObject);

            _subject.Intercept(invocation);
            var result = await(Task <ElementHandle[]>) invocation.ReturnValue;

            Assert.NotNull(result);
            Assert.IsType <ElementHandle[]>(result);
        }
Пример #15
0
        public async Task Intercept_sets_the_ReturnValue_to_Task_of_ElementObject_for_property_on_PageObject_marked_with_SelectorAttribute()
        {
            var methodInfo = _pageObject.GetType().GetProperty(nameof(FakePageObject.SelectorForElementObject)).GetMethod;
            var invocation = new FakeInvocation(methodInfo, _pageObject);

            _subject.Intercept(invocation);
            var result = await(Task <FakeElementObject>) invocation.ReturnValue;

            Assert.NotNull(result);
            Assert.IsAssignableFrom <FakeElementObject>(result);
        }
        public async Task GetReturnValueAsync_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.GetReturnValueAsync(pageObject, new XPathAttribute("//div"));

            Assert.Null(result);
        }
        public async Task GetReturnValueAsync_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.GetReturnValueAsync(pageObject, new SelectorAttribute("div"));

            Assert.NotNull(result);
            Assert.IsType <ElementHandle[]>(result);
        }
Пример #18
0
        public async Task GetReturnValue_returns_ElementObject_for_property_on_PageObject_marked_with_SelectorAttribute()
        {
            var pageObject = new FakePageObject();

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

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

            Assert.NotNull(result);
            Assert.IsAssignableFrom <FakeElementObject>(result);
        }
        public async Task GetReturnValueAsync_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.GetReturnValueAsync(pageObject, new XPathAttribute("//div"));

            Assert.NotNull(result);
            Assert.IsAssignableFrom <FakeElementObject[]>(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);
        }