Ejemplo n.º 1
0
        public void TestHeaderBasic()
        {
            var mh = new MsgHeader();

            mh["foo"] = "bar";
            Assert.Equal("bar", mh["foo"]);

            // check iteration
            foreach (string key in mh)
            {
                Assert.Equal("foo", key);
                Assert.Equal("bar", mh[key]);
            }

            // check iteration
            foreach (string key in mh)
            {
                Assert.Equal("foo", key);
                Assert.Equal("bar", mh[key]);
            }

            mh["baz"] = "nnn";
            Assert.True(mh.Count == 2);

            // check that baz has been removed.
            mh.Remove("baz");
            Assert.True(mh.Count == 1);

            // reassign and check for null
            mh["foo"] = null;
            Assert.True(mh["foo"] == null);

            // test clearing it out
            mh.Clear();
            Assert.True(mh.Count == 0);

            // test quoted string
            mh["foo"] = "\"mystring:bar;foo:\"";
            Assert.Equal("\"mystring:bar;foo:\"", mh["foo"]);
        }