示例#1
0
        public void ShouldThrowWhenIncorrectlyIndexed()
        {
            var t = new HeaderTable(400);

            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(-1));
            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(0));
            t.GetAt(1);  // Valid
            t.GetAt(61); // Last valid
            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(62));

            // Put something into the dynamic table and test again
            t.Insert("a", 1, "b", 1);
            t.Insert("a", 1, "b", 1);
            t.GetAt(62);
            t.GetAt(63);
            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(64));
        }
示例#2
0
        public void ShouldReturnItemsFromDynamicTable()
        {
            var t = new HeaderTable(400);

            t.Insert("a", 1, "b", 2);
            t.Insert("c", 3, "d", 4);
            var item = t.GetAt(62);

            Assert.Equal(
                new TableEntry {
                Name = "c", NameLen = 3, Value = "d", ValueLen = 4
            },
                item, ec);
            item = t.GetAt(63);
            Assert.Equal(
                new TableEntry {
                Name = "a", NameLen = 1, Value = "b", ValueLen = 2
            },
                item, ec);
        }