예제 #1
0
        public void NonNullDictionary_Unit_TryGetValue_KeyIsNull()
        {
            IDictionary<String, String> dictionary = new Dictionary<String, String>() {
                { "Key1", "Value1" },
                { "Key2", "Value2" },
                { "Key3", "Value3" }
            };
            NonNullDictionary<String, String> target = new NonNullDictionary<String, String>(dictionary);
            String key = null;
            String value;

            target.TryGetValue(key, out value);
        }
예제 #2
0
        public void NonNullDictionary_Unit_TryGetValue_Optimal()
        {
            IDictionary<String, String> dictionary = new Dictionary<String, String>() {
                { "Key1", "Value1" },
                { "Key2", "Value2" },
                { "Key3", "Value3" }
            };
            NonNullDictionary<String, String> target = new NonNullDictionary<String, String>(dictionary);
            String key = dictionary.Keys.First();
            String value;

            Boolean actual = target.TryGetValue(key, out value);
            Assert.AreEqual(true, actual);
            Assert.AreEqual(dictionary[key], value);
        }
예제 #3
0
        public void NonNullDictionary_Unit_TryGetValue_KeyDoesNotExist()
        {
            IDictionary<String, String> dictionary = new Dictionary<String, String>() {
                { "Key1", "Value1" },
                { "Key2", "Value2" },
                { "Key3", "Value3" }
            };
            NonNullDictionary<String, String> target = new NonNullDictionary<String, String>(dictionary);
            String key = "MyKey";
            String value;

            Boolean actual = target.TryGetValue(key, out value);
            Assert.AreEqual(false, actual);
            Assert.IsNull(value);
        }