public void GetValueReturnsValue <T>(T value)
        {
            // Arrange
            IDictionary <string, object> dict = new Dictionary <string, object>()
            {
                { "key", value }
            };

            // Act
            T resultValue = DictionaryExtensions.GetValue <T>(dict, "key");

            // Assert
            Assert.Equal(typeof(T), resultValue.GetType());
            Assert.Equal(value, resultValue);
        }
        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);
        }
 public void GetValueThrowsOnNullCollection()
 {
     Assert.ThrowsArgumentNull(() => DictionaryExtensions.GetValue <string>(null, String.Empty), "collection");
 }
        public void TryGetValueThrowsOnNullCollection()
        {
            string value;

            Assert.ThrowsArgumentNull(() => DictionaryExtensions.TryGetValue <string>(null, String.Empty, out value), "collection");
        }