示例#1
0
        public void QueryString_GetEnumerator_ItemsEnumerator()
        {
            //------------Setup for test--------------------------
            var items = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("key", "value")
            };

            var queryString = new QueryString(items);

            //------------Execute Test---------------------------
            var enumerator = queryString.GetEnumerator();

            //------------Assert Results-------------------------
            Assert.IsNotNull(enumerator);
            var count = 0;

            while (enumerator.MoveNext())
            {
                count++;
                var current = enumerator.Current;
                Assert.AreEqual(current.Key, "key");
                Assert.AreEqual(current.Value, "value");
            }
            Assert.AreEqual(1, count);
        }
        public void Enumerator()
        {
            var queryString = new QueryString();
            queryString["a"] = "b";
            queryString["c"] = "d";

            var enumerator = queryString.GetEnumerator();
            enumerator.MoveNext();
            dynamic item1 = enumerator.Current;
            Assert.Equal("a", item1.Key);
            Assert.Equal("b", item1.Value);
            enumerator.MoveNext();
            dynamic item2 = enumerator.Current;
            Assert.Equal("c", item2.Key);
            Assert.Equal("d", item2.Value);
        }