Exemple #1
0
        public void ReadOnlyDictionaryNonGenericEnumeration()
        {
            var         backing    = new Dictionary <string, string>();
            var         collection = new ObjectModel.ReadOnlyDictionary <string, string>(backing);
            IEnumerable enumerable = (IEnumerable)collection;

            // Does not overflow stack:
            foreach (object o in enumerable)
            {
            }
        }
Exemple #2
0
        public void ReadOnlyDictionaryWrapper()
        {
            var dictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            dictionary.Add("p", "v");

            var readOnlyDictionary = new ObjectModel.ReadOnlyDictionary <string, string>(dictionary);

            dictionary.Add("p2", "v2");

            Assert.Equal(2, dictionary.Count);
            Assert.True(dictionary.ContainsKey("p2"));
        }
Exemple #3
0
        public void ReadOnlyDictionaryNullBackingWrapper()
        {
            var dictionary = new ObjectModel.ReadOnlyDictionary <string, string>(new Dictionary <string, string>(0));

            Assert.Empty(dictionary);
        }
        public void ReadOnlyDictionaryNullBackingWrapper()
        {
            var dictionary = new ObjectModel.ReadOnlyDictionary <string, string>(new Dictionary <string, string>(0));

            Assert.Equal(0, dictionary.Count);
        }