public static TypedForm <T> SelectConfirm <T>(this TypedForm <T> form, Expression <Func <T, bool> > property, bool check)
        {
            var formName = FormName(property);

            form.GetSingle(formName).SetSend(check);
            return(form);
        }
        public static TypedForm <T> SetText <T, U>(this TypedForm <T> form, Expression <Func <T, U> > property, string value)
        {
            var formName = FormName(property);

            form.GetSingle(formName).SetValue(value);
            return(form);
        }
        public static void WhenCheckedShows <T>(this TypedForm <T> form, Expression <Func <T, bool> > property, string elementId)
        {
            var idSelector = "#" + elementId;
            var element    = form.Element.Find(idSelector);
            var name       = FormName(property);

            element.Attribute("data-checkbox-checked-show").Should().Be(name, "element id {0} should be configured to show when {1} is checked", elementId, name);
        }
        public static TypedForm <T> SetDate <T>(this TypedForm <T> form, Expression <Func <T, DateTime?> > property, string day, string month, string year)
        {
            var formName = FormName(property);

            form.GetSingle(formName + "_day").SetValue(day);
            form.GetSingle(formName + "_month").SetValue(month);
            form.GetSingle(formName + "_year").SetValue(year);
            return(form);
        }
        public static void RadioShows <T>(this TypedForm <T> form, Expression <Func <T, bool?> > property, bool?value, string elementId)
        {
            var idSelector  = "#" + elementId;
            var element     = form.Element.Find(idSelector);
            var name        = FormName(property);
            var stringValue = value.HasValue ? value.Value.ToString() : "";

            element.Attribute("data-radio-show-name").Should().Be(name, "element id {0} should be configured to show/hide for {1}", elementId, name);
            element.Attribute("data-radio-show-value").Should().Be(stringValue, "element id {0} should be configured to show when {1} value is {2}", elementId, name, stringValue);
        }
Example #6
0
        public virtual TypedForm <T> Scrape <T>(string documentUrl)
        {
            var method = _element.AttributeOrEmpty("method");
            var action = _element.AttributeOrEmpty("action");

            if (string.IsNullOrWhiteSpace(action))
            {
                action = documentUrl;
            }

            var form = new TypedForm <T>(_element, method, action);

            AddInputs(form);
            return(form);
        }
        public static AjaxAction[] OnChange <T>(this TypedForm <T> form, Expression <Func <T, object> > property, ISimulatedHttpClient client)
        {
            var formGroupSelector = "#" + FormName(property) + "_FormGroup";
            var formGroup         = form.Element.Find(formGroupSelector);
            var changeUrl         = formGroup.Attribute("data-ajax-change");

            form.SetAction(changeUrl);
            var ajaxResponse = form.Submit(client, r => r.SetExpectedResponse(HttpStatusCode.OK));
            var json         = ajaxResponse.Text;
            var settings     = new JsonSerializerSettings {
                ContractResolver = new Repository.RepositoryContractResolver()
            };
            var ajaxActions = JsonConvert.DeserializeObject <AjaxAction[]>(json, settings);

            return(ajaxActions);
        }
Example #8
0
        protected virtual void AddInputs <T>(TypedForm <T> form)
        {
            var formInputs = _element.FindAll("input, select, textarea, button");

            var submits = formInputs.Where(i => IsSubmit(i));
            var inputs  = formInputs.Where(i => !IsSubmit(i));

            foreach (var submit in submits)
            {
                AddSubmit(form, submit);
            }

            var formValues = FormValueScraper.FromElements(inputs);

            foreach (var formValue in formValues)
            {
                form.AddFormValue(formValue);
            }
        }
 public static TypedForm <T> SelectNo <T, U>(this TypedForm <T> form, Expression <Func <T, U> > property)
 {
     return(form.SetText(property, "False"));
 }
        public static bool GetConfirm <T>(this TypedForm <T> form, Expression <Func <T, bool> > property)
        {
            var formName = FormName(property);

            return(form.GetSingle(formName).Value == "True");
        }
        public static FormValue[] Get <T, U>(this TypedForm <T> form, Expression <Func <T, U> > property)
        {
            var formName = FormName(property);

            return(form.Get(formName));
        }
Example #12
0
        protected virtual void AddSubmit <T>(TypedForm <T> form, ElementWrapper inputSubmit)
        {
            var submitValue = SubmitValue.FromElement(inputSubmit);

            form.AddSubmitValue(submitValue);
        }