public void Model(TModel viewModel, IDictionary <Type, Func <object, string> > propertyTypeHandling = null) { var type = typeof(TModel); foreach (var property in type.GetProperties()) { var propertyName = property.Name; var propertyValue = property.GetValue(viewModel, null); if (property.GetCustomAttributes(typeof(HiddenInputAttribute), false).Length > 0) { continue; } if (property.GetCustomAttributes(typeof(ScaffoldColumnAttribute), false).Length > 0) { continue; } if (propertyValue == null) { continue; } var stringValue = GetStringValue(propertyTypeHandling, propertyValue, property); var textBox = _componentFactory.HtmlControlFor <TextBox>(propertyName); textBox.ReplaceInputValueWith(stringValue); } }
public void Given_a_drop_down_exists() { _componentFactory = SubstituteFor <IComponentFactory>(); _dropDown = Substitute.For <DropDown>(); _componentFactory .HtmlControlFor <DropDown>(_dropDownPropertySelector) .Returns(_dropDown); }
public void Given_the_element_exists() { _componentFactory = SubstituteFor <IComponentFactory>(); _control = SubstituteFor <IHtmlControl>(); _componentFactory .HtmlControlFor <IHtmlControl>(_propertySelector) .Returns(_control); }
public void Given_a_drop_down_has_a_selected_option() { _componentFactory = SubstituteFor <IComponentFactory>(); _checkBox = Substitute.For <CheckBox>(); _componentFactory .HtmlControlFor <CheckBox>(_propertySelector) .Returns(_checkBox); }
public void Given_a_web_element_has_an_attribute_data_value() { _componentFactory = SubstituteFor<IComponentFactory>(); _textBox = Substitute.For<TextBox>(); _componentFactory .HtmlControlFor<TextBox>(_textBoxPropertySelector) .Returns(_textBox); }
public void Given_a_drop_down_exists() { _componentFactory = SubstituteFor<IComponentFactory>(); _radioButtonGroup = Substitute.For<RadioButtonGroup>(); _componentFactory .HtmlControlFor<RadioButtonGroup>(_radioButtonGroupPropertySelector) .Returns(_radioButtonGroup); }
public void Given_a_text_area_contains_multiple_lines_of_content() { _textArea = Substitute.For<TextArea>(); _componentFactory = SubstituteFor<IComponentFactory>(); _componentFactory .HtmlControlFor<TextArea>(_propertySelector) .Returns(_textArea); }
public void Given_a_drop_down_exists() { _componentFactory = SubstituteFor<IComponentFactory>(); _dropDown = Substitute.For<DropDown>(); _componentFactory .HtmlControlFor<DropDown>(_dropDownPropertySelector) .Returns(_dropDown); }
public void Given_a_drop_down_exists() { _componentFactory = SubstituteFor <IComponentFactory>(); _radioButtonGroup = Substitute.For <RadioButtonGroup>(); _componentFactory .HtmlControlFor <RadioButtonGroup>(_radioButtonGroupPropertySelector) .Returns(_radioButtonGroup); }
public void Given_a_web_element_has_an_attribute_data_value() { _componentFactory = SubstituteFor <IComponentFactory>(); _textBox = Substitute.For <TextBox>(); _componentFactory .HtmlControlFor <TextBox>(_textBoxPropertySelector) .Returns(_textBox); }
public void Given_a_text_area_contains_multiple_lines_of_content() { _textArea = Substitute.For <TextArea>(); _componentFactory = SubstituteFor <IComponentFactory>(); _componentFactory .HtmlControlFor <TextArea>(_propertySelector) .Returns(_textArea); }
public void Given_a_drop_down_has_a_selected_option() { _componentFactory = SubstituteFor<IComponentFactory>(); _checkBox = Substitute.For<CheckBox>(); _componentFactory .HtmlControlFor<CheckBox>(_propertySelector) .Returns(_checkBox); }
public void Given_the_element_exists() { _componentFactory = SubstituteFor<IComponentFactory>(); _control = SubstituteFor<IHtmlControl>(); _componentFactory .HtmlControlFor<IHtmlControl>(_propertySelector) .Returns(_control); }
private void InputProperty(object o, ParameterExpression parentParameter, LambdaExpression expression, IDictionary <Type, Func <object, string> > propertyTypeHandling, PropertyInfo property) { var customAttributes = property.GetCustomAttributes(false); if (customAttributes.OfType <HiddenInputAttribute>().Any()) { return; } if (customAttributes.OfType <ScaffoldColumnAttribute>().Any(x => !x.Scaffold)) { return; } if (customAttributes.OfType <ReadOnlyAttribute>().Any(x => x.IsReadOnly)) { return; } var propertyValue = property.GetValue(o, null); if (propertyValue == null) { return; } var p = Expression.Property(expression != null ? expression.Body : parentParameter, property); var propertyExpression = Expression.Lambda(p, parentParameter); if (!property.PropertyType.IsValueType && property.PropertyType != typeof(string)) { Input(propertyValue, parentParameter, propertyExpression, propertyTypeHandling); return; } var stringValue = GetStringValue(propertyTypeHandling, propertyValue, property.PropertyType); var ctrl = _componentFactory.HtmlControlFor <TextBox>(propertyExpression); ctrl.ReplaceInputValueWith(stringValue); }
public void Given_a_drop_down_has_a_selected_option() { _componentFactory = SubstituteFor <IComponentFactory>(); _dropDown = Substitute.For <DropDown>(); _componentFactory .HtmlControlFor <DropDown>(_dropDownPropertySelector) .Returns(_dropDown); _dropDown.SelectedElementText.Returns("Selected option...."); }
public void Given_a_drop_down_has_a_selected_option() { _componentFactory = SubstituteFor<IComponentFactory>(); _dropDown = Substitute.For<DropDown>(); _componentFactory .HtmlControlFor<DropDown>(_dropDownPropertySelector) .Returns(_dropDown); _dropDown.SelectedElementText.Returns("Selected option...."); }
public void Given_a_radio_group_has_a_selected_radio_button() { _componentFactory = SubstituteFor <IComponentFactory>(); _radioButtonGroup = Substitute.For <RadioButtonGroup>(); _componentFactory .HtmlControlFor <RadioButtonGroup>(_radioGroupPropertySelector) .Returns(_radioButtonGroup); _radioButtonGroup.SelectedElementAs <ChoiceType>().Returns(ChoiceType.Another); }
public void Given_a_radio_group_has_a_selected_radio_button() { _componentFactory = SubstituteFor<IComponentFactory>(); _radioButtonGroup = Substitute.For<RadioButtonGroup>(); _componentFactory .HtmlControlFor<RadioButtonGroup>(_radioGroupPropertySelector) .Returns(_radioButtonGroup); _radioButtonGroup.SelectedElementAs<ChoiceType>().Returns(ChoiceType.Another); }
public virtual bool CheckBoxValue <TProperty>(Expression <Func <TViewModel, TProperty> > checkBoxPropertySelector, TimeSpan maxWait = default(TimeSpan)) { return(_componentFactory .HtmlControlFor <CheckBox>(checkBoxPropertySelector, maxWait) .Checked); }