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); }
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); }
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); }