Exemple #1
0
        public void HeadersList()
        {
            var collection = new HeadersList(new[]
            {
                new KeyValuePair <string, string>("myKey1", "myValue1"),
                new KeyValuePair <string, string>("myKey2", "myValue2"),
                new KeyValuePair <string, string>("myKey3", "myValue3"),
                new KeyValuePair <string, string>("myKey4", "myValue4"),
                new KeyValuePair <string, string>("myKey5", "myValue5"),
                new KeyValuePair <string, string>("myKey6", "myValue6"),
                new KeyValuePair <string, string>("myKey7", "myValue7"),
                new KeyValuePair <string, string>("myKey8", "myValue8"),
                new KeyValuePair <string, string>("myKey9", "myValue9"),
                new KeyValuePair <string, string>("myKey0", "myValue0")
            });

            Assert.Equal(collection.Count, 10);
            Assert.Equal(collection.StoredHeadersSize, 60 + 80 + 32 * collection.Count);

            collection.Add(new KeyValuePair <string, string>("someAddKey1", "someAddValue1"));
            collection.Add(new KeyValuePair <string, string>("someAddKey2", "someAddValue2"));

            Assert.Equal(collection.Count, 12);
            Assert.Equal(collection.StoredHeadersSize, 60 + 80 + 32 * collection.Count + 22 + 26);

            int headersSize = collection.Sum(header => header.Key.Length + header.Value.Length + 32);

            Assert.Equal(collection.StoredHeadersSize, headersSize);
        }