コード例 #1
0
        public void AsReadOnly()
        {
            Assert.IsTrue(_list.Equals(_readOnly));

            _list[2] = new StringKeyed("two", "foo value");
            Assert.IsTrue(_list.Equals(_readOnly));

            _list[2] = new StringKeyed("two", "second value");
            Assert.IsTrue(_list.Equals(_readOnly));
        }
コード例 #2
0
        public void Constructor()
        {
            StringStringList list = new StringStringList(567, item => item.Key);

            list.Add(new StringKeyed("foo", "foo value"));
            list.Add(new StringKeyed("bar", "bar value"));
            Assert.AreEqual(567, list.Capacity);
            Assert.AreEqual(2, list.Count);

            StringKeyed[] array = new StringKeyed[4] {
                new StringKeyed("a", "a value"),
                new StringKeyed("b", "b value"),
                new StringKeyed("c", "c value"),
                new StringKeyed("d", "d value")
            };

            list = new StringStringList(array, item => item.Key);
            Assert.AreEqual(4, list.Capacity);
            Assert.AreEqual(4, list.Count);
        }