Пример #1
0
 public void When_Creating_element_With_Dictionary_Sticks()
 {
     var hash = new Hash {{"Key1", "Val1"}, {"Key2", "Val2"}, {"Key3", "Val3"}};
     var element = new CheckBoxField(hash);
     Assert.That(element.Tag, Is.EqualTo("input"));
     Assert.That(element.Attributes.Count == 4);
     Assert.That(element["Key1"] == "Val1");
 }
Пример #2
0
 public void Properties_Stick_When_Set()
 {
     var element = new CheckBoxField();
     Assert.That(element.Checked == null);
     element.Checked = true;
     Assert.That(element.Checked == true);
     Assert.That(element["checked"] == "checked");
     element.Checked = null;
     Assert.That(element.Checked == null);
 }
            public void Then_ToString_should_produce_correct_html()
            {
                var field1 = new CheckBoxField(new Hash(name => "foo", value => "bar"));
                var field2 = new CheckBoxField(new Hash(name => "x", value => "y"));
                string expected = string.Concat(field1, field2);

                var list = new InputElementList<CheckBoxField>(Hash.Empty) {field1, field2};
                string html = list.ToString();

                Assert.That(html, Is.EqualTo(expected));
            }
            public void Enumerating_should_return_checkboxes()
            {
                var field1 = new CheckBoxField(new Hash(name => "foo", value => "bar"));
                var field2 = new CheckBoxField(new Hash(name => "x", value => "y"));

                var list = new InputElementList<CheckBoxField>(Hash.Empty) {field1, field2};

                var boxes = new List<CheckBoxField>();

                foreach(var field in list)
                {
                    boxes.Add(field);
                }

                Assert.That(boxes.Count, Is.EqualTo(2));
                Assert.That(boxes[0], Is.EqualTo(field1));
                Assert.That(boxes[1], Is.EqualTo(field2));
            }
Пример #5
0
 public void When_label_specified_manually_it_should_stick()
 {
     var field = new CheckBoxField {Label = "Foo"};
     Assert.That(field.Label, Is.EqualTo("Foo"));
 }
Пример #6
0
 public void When_label_is_in_attributes_it_should_be_removed()
 {
     var field = new CheckBoxField(new Hash(label => "Foo"));
     Assert.That(field.Label, Is.EqualTo("Foo"));
     Assert.That(field.Attributes.ContainsKey("label"), Is.False);
 }
Пример #7
0
 public void ToString_should_render_label()
 {
     string expected = "<input id=\"foo\" type=\"checkbox\"/><label for=\"foo\">Bar</label>";
     var field = new CheckBoxField(new Hash(id => "foo", label => "Bar"));
     string html = field.ToString();
     Assert.That(html, Is.EqualTo(expected));
 }
Пример #8
0
 public void ToString_should_not_render_label_with_no_id()
 {
     string expected = "<input type=\"checkbox\"/>";
     var field = new CheckBoxField(new Hash(label => "Bar"));
     string html = field.ToString();
     Assert.That(html, Is.EqualTo(expected));
 }
Пример #9
0
 public void Tag_Is_Correct()
 {
     var element = new CheckBoxField();
     Assert.That(element.Tag, Is.EqualTo("input"));
     Assert.That(element.Type, Is.EqualTo("checkbox"));
 }