コード例 #1
0
        public void GetValue_ReturnsCorrectly()
        {
            var dictionary = new LazyDictionary <int, string>
            {
                { 42, () => "42" }
            };

            Assert.AreEqual("42", dictionary[42]);
        }
コード例 #2
0
        public void ContainsKey_OnlyReturnsTrue_IfValueCanBeFound()
        {
            var dictionary = new LazyDictionary <int, string>
            {
                { 42, () => "42" }
            };

            Assert.IsFalse(dictionary.ContainsKey(1));
            Assert.IsTrue(dictionary.ContainsKey(42));
        }
コード例 #3
0
        public void TryGetValue_ReturnsCorrectly()
        {
            var dictionary = new LazyDictionary <int, string>
            {
                { 42, () => "42" }
            };

            string value = null;

            Assert.IsFalse(dictionary.TryGetValue(1, out value));
            Assert.IsTrue(dictionary.TryGetValue(42, out value));
            Assert.AreEqual("42", value);
        }