示例#1
0
        public void GetValueFromDataCollectionTest()
        {
            var data   = new NameValueCollection();
            var target = new NullBooleanSelect();

            Assert.AreEqual(null, target.GetValueFromDataCollection(data, null, "test"));

            data["test"] = "";
            Assert.AreEqual(null, target.GetValueFromDataCollection(data, null, "test"));

            data["test"] = "1";
            Assert.AreEqual(null, target.GetValueFromDataCollection(data, null, "test"));

            data["test"] = bool.TrueString;
            Assert.AreEqual(true, target.GetValueFromDataCollection(data, null, "test"));

            data["test"] = "2";
            Assert.AreEqual(true, target.GetValueFromDataCollection(data, null, "test"));

            data["test"] = bool.FalseString;
            Assert.AreEqual(false, target.GetValueFromDataCollection(data, null, "test"));

            data["test"] = "3";
            Assert.AreEqual(false, target.GetValueFromDataCollection(data, null, "test"));
        }
示例#2
0
        public void RenderTest()
        {
            NullBooleanSelect target = new NullBooleanSelect();

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\" selected=\"selected\">Unknown</option>\n<option value=\"2\">Yes</option>\n<option value=\"3\">No</option>\n</select>",
                            target.Render("Test1", null));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\" selected=\"selected\">Unknown</option>\n<option value=\"2\">Yes</option>\n<option value=\"3\">No</option>\n</select>",
                            target.Render("Test1", ""));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\" selected=\"selected\">Unknown</option>\n<option value=\"2\">Yes</option>\n<option value=\"3\">No</option>\n</select>",
                            target.Render("Test1", "1"));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\">Unknown</option>\n<option value=\"2\" selected=\"selected\">Yes</option>\n<option value=\"3\">No</option>\n</select>",
                            target.Render("Test1", bool.TrueString));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\">Unknown</option>\n<option value=\"2\" selected=\"selected\">Yes</option>\n<option value=\"3\">No</option>\n</select>",
                            target.Render("Test1", true));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\">Unknown</option>\n<option value=\"2\" selected=\"selected\">Yes</option>\n<option value=\"3\">No</option>\n</select>",
                            target.Render("Test1", "2"));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\">Unknown</option>\n<option value=\"2\">Yes</option>\n<option value=\"3\" selected=\"selected\">No</option>\n</select>",
                            target.Render("Test1", bool.FalseString));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\">Unknown</option>\n<option value=\"2\">Yes</option>\n<option value=\"3\" selected=\"selected\">No</option>\n</select>",
                            target.Render("Test1", false));

            Assert.AreEqual("<select name=\"Test1\">\n<option value=\"1\">Unknown</option>\n<option value=\"2\">Yes</option>\n<option value=\"3\" selected=\"selected\">No</option>\n</select>",
                            target.Render("Test1", "3"));
        }
示例#3
0
 public void NullBooleanSelectConstructorTest()
 {
     NullBooleanSelect target = new NullBooleanSelect();
     // Pass
 }