public void DictionaryTypeObject_GetValueOrDefault_FindsValue(Type key) { // Arrange this.typeObjDict.Add(key, "value"); // Act string actual = DictionaryExtensions.GetValueOrDefault <string>(this.typeObjDict, key); // Assert Assert.Equal("value", actual); }
public void DictionaryStringObject_GetValueOrDefault_FindsValue <T>(string key, T value) { // Arrange _strObjDict.Add(key, value); // Act T actual = DictionaryExtensions.GetValueOrDefault <T>(_strObjDict, key); // Assert Assert.Equal(value, actual); }
public void DictionaryStringString_GetValueOrDefault_FindsValue(string key) { // Arrange this.strStrDict.Add(key, "value"); // Act string actual = DictionaryExtensions.GetValueOrDefault(this.strStrDict, key); // Assert Assert.Equal("value", actual); }
public void DictionaryStringObject_TryGetValue_FindsValue <T>(string key, T value) { // Arrange _strObjDict.Add(key, value); // Act T actual; bool result = DictionaryExtensions.TryGetValue(_strObjDict, key, out actual); // Assert Assert.True(result); Assert.Equal(value, actual); }
public void DictionaryTypeObject_TryGetValue_FindsValue(Type key) { // Arrange this.typeObjDict.Add(key, "value"); // Act string actual; bool result = DictionaryExtensions.TryGetValue(this.typeObjDict, key, out actual); // Assert Assert.True(result); Assert.Equal("value", actual); }
public void TryGetValueReturnsTrue <T>(T value) { // Arrange IDictionary <string, object> dict = new Dictionary <string, object>() { { "key", value } }; // Act T resultValue; bool result = DictionaryExtensions.TryGetValue(dict, "key", out resultValue); // Assert Assert.True(result); Assert.Equal(typeof(T), resultValue.GetType()); Assert.Equal(value, resultValue); }
public void FindKeysWithPrefixRecognizesRootChilden() { // Arrange IDictionary <string, int> dict = new Dictionary <string, int>() { { "[0]", 1 }, { "Name", 2 }, { "Address.Street", 3 }, { "", 4 } }; // Act List <int> results = DictionaryExtensions.FindKeysWithPrefix <int>(dict, "").Select(kvp => kvp.Value).ToList(); // Assert Assert.Equal(4, results.Count); Assert.Contains(1, results); Assert.Contains(2, results); Assert.Contains(3, results); Assert.Contains(4, results); }