public void GetBooleanTest() { var q = new QueryString("a&b=&c=0&d=false&e=no&f=+FALSE+&g=%0d%0a"); foreach (string k in q.Keys) { Assert.IsFalse(q.GetBoolean(k, true)); } }
public void GetValueTest() { var q = new QueryString("someString=Hello%2C+world!&someInt=42&someBool=true"); Assert.AreEqual("Hello, world!", q.GetString("someString")); Assert.AreEqual("ABC", q.GetString("not-there", "ABC")); Assert.IsNull(q.GetString("NonExistant")); Assert.AreEqual(42, q.GetInt("someInt")); Assert.AreEqual(-14, q.GetInt("NonExistant", -14)); Assert.AreEqual(0, q.GetInt("not-there")); Assert.AreEqual(100, q.GetInt("someString", 100)); Assert.IsTrue(q.GetBoolean("someBool")); Assert.IsTrue(q.GetBoolean("not-there", true)); Assert.IsFalse(q.GetBoolean("not-there")); Assert.IsTrue(q.GetBoolean("someString")); Assert.IsTrue(q.GetBoolean("someInt")); }