public void ValuePairToString() { var valuePairs = "foo=bar&baz=qux&zap=zazzle"; ValuePairParser parser = new ValuePairParser(valuePairs); Assert.AreEqual(valuePairs, parser.ToString()); }
public void ValuePairParserFromString() { var valuePairs = "foo=bar&baz=qux&zap=zazzle"; ValuePairParser parser = new ValuePairParser(valuePairs); Assert.AreEqual(parser["foo"], "bar"); Assert.AreEqual(parser["baz"], "qux"); Assert.AreEqual(parser["zap"], "zazzle"); }
public void ValuePairParserFromInvalidString() { var valuePairs = "foo=bar=1&baz=qux&zap=zazzle"; ValuePairParser parser = new ValuePairParser(valuePairs); try { var value = parser["foo"]; Assert.Fail("Key should not exist"); } catch (KeyNotFoundException) { } catch (Exception) { Assert.Fail("Invalid exception"); throw; } Assert.AreEqual(parser["baz"], "qux"); Assert.AreEqual(parser["zap"], "zazzle"); }