public void EditorFor_DepthOfPropertiesAccess_CreatesInputMatchingProperties()
        {
            var customer = new Customer() { Name = "hammett", LinkedUser = new User() { Email = "*****@*****.**" } };
            var builder = new GenFormBuilder<Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[linkeduser][email]"" value=""*****@*****.**"" id=""customer_linkeduser_email""/>",
                builder.EditorFor(c => c.LinkedUser.Email).ToHtmlString());
        }
Beispiel #2
0
        public void EditorFor_DataText_CreatesInputText()
        {
            var customer = new Customer();
            var builder  = new GenFormBuilder <Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value="""" id=""customer_name""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }
        public void EditorFor_DataText_CreatesInputText()
        {
            var customer = new Customer();
            var builder = new GenFormBuilder<Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value="""" id=""customer_name""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }
Beispiel #4
0
        public void EditorFor_WithValue_CreatesInputWithValueEncoded()
        {
            var customer = new Customer()
            {
                Name = "hammett <ver>"
            };
            var builder = new GenFormBuilder <Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value=""hammett &lt;ver&gt;"" id=""customer_name""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }
        public void EditorFor_RequiredDataText_CreatesInputText()
        {
            var customer = new Customer();

            _modelProvider.Type2Meta[typeof(Customer)] = BuildMetadataFor<Customer>(() =>
                new Dictionary<PropertyInfo, ModelMetadata>()
                    {
                        { typeof(Customer).GetProperty("Name"), new ModelMetadata(typeof(Customer), typeof(Customer).GetProperty("Name")) { Required = new RequiredAttribute() { } } }
                    });
            var builder = new GenFormBuilder<Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value="""" id=""customer_name"" required aria-required=""true""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }
Beispiel #6
0
        public void EditorFor_DepthOfPropertiesAccess_CreatesInputMatchingProperties()
        {
            var customer = new Customer()
            {
                Name = "hammett", LinkedUser = new User()
                {
                    Email = "*****@*****.**"
                }
            };
            var builder = new GenFormBuilder <Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[linkeduser][email]"" value=""*****@*****.**"" id=""customer_linkeduser_email""/>",
                builder.EditorFor(c => c.LinkedUser.Email).ToHtmlString());
        }
Beispiel #7
0
        public void EditorFor_WithDefaultValue_CreatesInputText()
        {
            var customer = new Customer();

            _modelProvider.Type2Meta[typeof(Customer)] = BuildMetadataFor <Customer>(() =>
                                                                                     new Dictionary <PropertyInfo, ModelMetadata>()
            {
                { typeof(Customer).GetProperty("Name"),
                  new ModelMetadata(typeof(Customer), typeof(Customer).GetProperty("Name"))
                  {
                      DefaultValue = "def val"
                  } }
            });
            var builder = new GenFormBuilder <Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value="""" placeholder=""def val"" id=""customer_name""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }
Beispiel #8
0
        public void EditorFor_RequiredDataText_CreatesInputText()
        {
            var customer = new Customer();

            _modelProvider.Type2Meta[typeof(Customer)] = BuildMetadataFor <Customer>(() =>
                                                                                     new Dictionary <PropertyInfo, ModelMetadata>()
            {
                { typeof(Customer).GetProperty("Name"), new ModelMetadata(typeof(Customer), typeof(Customer).GetProperty("Name"))
                  {
                      Required = new RequiredAttribute()
                      {
                      }
                  } }
            });
            var builder = new GenFormBuilder <Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value="""" id=""customer_name"" required aria-required=""true""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }
        public void EditorFor_WithDefaultValue_CreatesInputText()
        {
            var customer = new Customer();
            _modelProvider.Type2Meta[typeof(Customer)] = BuildMetadataFor<Customer>(() =>
                new Dictionary<PropertyInfo, ModelMetadata>()
                    {
                        { typeof(Customer).GetProperty("Name"),
                            new ModelMetadata(typeof(Customer), typeof(Customer).GetProperty("Name")) { DefaultValue = "def val" } }
                    });
            var builder = new GenFormBuilder<Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value="""" placeholder=""def val"" id=""customer_name""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }
        public void EditorFor_WithValue_CreatesInputWithValueEncoded()
        {
            var customer = new Customer() { Name = "hammett <ver>" };
            var builder = new GenFormBuilder<Customer>("customer", _writer, _helperContext, customer);

            Assert.AreEqual(
                @"<input type=""text"" name=""customer[name]"" value=""hammett &lt;ver&gt;"" id=""customer_name""/>",
                builder.EditorFor(c => c.Name).ToHtmlString());
        }