Exemplo n.º 1
0
 public void Create_Select_With_Selected_Value_From_Complex_Object()
 {
     var element = new Select {ValueField = "Id", TextField = "Name"};
     var person1 = new Person("Hillary", 1);
     var person2 = new Person("Barak", 2);
     var person3 = new Person("John", 3);
     element.AddOption(person1.Id.ToString(), person1.Name);
     element.AddOption(person2.Id.ToString(), person2.Name);
     element.AddOption(person3.Id.ToString(), person3.Name);
     element.SetSelectedValues(person1);
     Assert.That(element.ToString(), Is.EqualTo("<select ><option value=\"1\" selected=\"selected\">Hillary</option><option value=\"2\">Barak</option><option value=\"3\">John</option></select>"));
 }
Exemplo n.º 2
0
 public void Create_Select_With_Multiple_Options_Selected()
 {
     var element = new Select();
     element.AddOption("value1", "text1");
     element.AddOption("value2", "text2");
     element.FirstOptionValue = "FirstValue";
     element.FirstOption = "FirstText";
     element.SetSelectedValues(new object[] { "value2", "FirstValue" });
     Assert.That(element.ToString(), Is.EqualTo("<select ><option value=\"FirstValue\" selected=\"selected\">FirstText</option><option value=\"value1\">text1</option><option value=\"value2\" selected=\"selected\">text2</option></select>"));
 }
Exemplo n.º 3
0
 public void Create_Select_With_Options()
 {
     var element = new Select();
     var opt = new Option {InnerText = "text", Value = "value"};
     element.Options.Add(opt);
     element.AddOption("value2", "text2");
     element.FirstOptionValue = "FirstValue";
     element.FirstOption = "FirstText";
     element.SetSelectedValues("value2");
     Assert.That(element.ToString(), Is.EqualTo("<select ><option value=\"FirstValue\">FirstText</option><option value=\"value\">text</option><option value=\"value2\" selected=\"selected\">text2</option></select>"));
 }
Exemplo n.º 4
0
 public void Create_Select_Null_Value_Selects_Empty_String_Option()
 {
     var element = new Select();
     element.AddOption("value1", "text1");
     element.AddOption("value2", "text2");
     element.FirstOptionValue = "";
     element.FirstOption = "-Choose-";
     element.SetSelectedValues(new object[] { null });
     Assert.That(element.ToString(), Is.EqualTo("<select ><option value=\"\" selected=\"selected\">-Choose-</option><option value=\"value1\">text1</option><option value=\"value2\">text2</option></select>"));
 }