コード例 #1
0
        public static object CreateFieldValue(FieldInfo fieldInfo, ValueConstructionInfo info)
        {
            var criteria    = fieldInfo.FindAttr <FindByAttribute>().SafeGet(a => a.GetCriteria());
            var refinedInfo = info.RefineWith(criteria);

            return(CreateValue(refinedInfo));
        }
コード例 #2
0
        public void InjectBrowser()
        {
            var fieldInfo = typeof(Sample).GetField("Browser");
            var info      = new ValueConstructionInfo(fieldInfo.FieldType, new[] { pageObjectElement }, browser);
            var value     = WebElementGetExtensions.CreateFieldValue(fieldInfo, info);

            Assert.AreEqual(browser, value);
        }
コード例 #3
0
        public void InjectPageObject()
        {
            var fieldInfo = typeof(Sample).GetField("Control");
            var info      = new ValueConstructionInfo(fieldInfo.FieldType, new[] { pageObjectElement }, browser);
            var value     = (PageObject)WebElementGetExtensions.CreateFieldValue(fieldInfo, info);

            Assert.AreEqual(browser, value.Browser);
            Assert.AreEqual(controlElement, value.Element);
        }
コード例 #4
0
 private static object GetLazyFieldValue(ValueConstructionInfo info)
 {
     return(LazyUtils.MakeLazy(
                info.ValueType,
                () => CreateValue(
                    new ValueConstructionInfo(
                        info.ValueType.GetGenericArguments().Single(),
                        info.Elements,
                        info.Browser))));
 }
コード例 #5
0
        public static object CreateValue(ValueConstructionInfo info)
        {
            var factory = factories.FirstOrDefault(f => f.CanCreate(info.ValueType));

            if (factory == null)
            {
                throw new WebDriverException(string.Format("Unsupported type {0}", info.ValueType));
            }
            try
            {
                return(factory.Create(info));
            }
            catch (WebDriverException e)
            {
                throw new WebDriverException("Can't create " + info.ValueType.Name + ". " + e.Message, e);
            }
        }
コード例 #6
0
 private static object CreateArray(ValueConstructionInfo info)
 {
     return(All(info.Elements, info.ValueType, info.Browser).ToArray(info.ValueType));
 }
コード例 #7
0
        private static object GetPageObjectArrayFieldValue(ValueConstructionInfo info)
        {
            var elementType = info.ValueType.GetElementType();

            return(CreateArray(new ValueConstructionInfo(elementType, info.Elements, info.Browser)));
        }
コード例 #8
0
 private static object GetPageObjectFieldValue(ValueConstructionInfo info)
 {
     return(Get(info.Elements, info.ValueType, info.Browser));
 }