예제 #1
0
        public void ValuePairToString()
        {
            var valuePairs = "foo=bar&baz=qux&zap=zazzle";

            ValuePairParser parser = new ValuePairParser(valuePairs);

            Assert.AreEqual(valuePairs, parser.ToString());
        }
예제 #2
0
        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");
        }
예제 #3
0
        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");
        }