public void Setup()
        {
            _fc = Substitute.For<IFieldConfiguration>();

            _f = Substitute.For<IForm<TestFieldViewModel, IFormTemplate>>();
            _f.Template.BeginField(_label, _field, _validation, _metadata, Arg.Any<IReadonlyFieldConfiguration>(), Arg.Any<bool>()).Returns(_beginHtml);
            _f.Template.Field(_label, _field, _validation, _metadata, Arg.Any<IReadonlyFieldConfiguration>(), Arg.Any<bool>()).Returns(_html);
            _f.Template.EndField().Returns(_endHtml);

            _g = Substitute.For<IFieldGenerator>();
            _g.GetLabelHtml(Arg.Any<IReadonlyFieldConfiguration>()).Returns(_label);
            _g.GetFieldHtml(Arg.Any<IReadonlyFieldConfiguration>()).Returns(_field);
            _g.GetValidationHtml(Arg.Any<IReadonlyFieldConfiguration>()).Returns(_validation);
            _g.Metadata.Returns(_metadata);
            _g.GetFieldId().Returns(FieldId);

            var autoSubstitute = AutoSubstituteContainer.Create();
            var helper = autoSubstitute.Resolve<HtmlHelpers<TestFieldViewModel>>();
            _f.HtmlHelper.Returns(helper);
            _f.GetFieldGenerator(Arg.Any<Expression<Func<TestFieldViewModel, string>>>()).Returns(_g);
        }
 public IFieldConfiguration ModifyConfig(IFieldConfiguration config)
 {
     if (_aslist)
         config.AsRadioList();
     return config;
 }
 public void Setup()
 {
     _fieldConfiguration = new FieldConfiguration();
 }
 /// <summary>
 /// Creates a <see cref="ReadonlyFieldConfiguration"/> that wraps the provided <see cref="IFieldConfiguration"/>.
 /// </summary>
 /// <param name="fieldConfiguration">The field configuration to wrap</param>
 public ReadonlyFieldConfiguration(IFieldConfiguration fieldConfiguration)
 {
     _fieldConfiguration = fieldConfiguration ?? new FieldConfiguration();
 }
Esempio n. 5
0
        public void Pass_lazy_initialised_field_into_field_configuration()
        {
            _fc = new FieldConfiguration();
            var field = Arrange(false);
            _fc.SetField(() => field);

            Assert.That(_fc.ToHtmlString(), Is.EqualTo(field.ToHtmlString()));
        }
Esempio n. 6
0
        public void Pass_field_into_field_configuration()
        {
            _fc = new FieldConfiguration();
            var field = Arrange(false);

            Assert.That(_fc.ToHtmlString(), Is.EqualTo(field.ToHtmlString()));
        }