Esempio n. 1
0
        public void Chaining_Dictionary()
        {
            var dict = new System.Collections.Generic.Dictionary <int, int> {
                [1] = 2, [3] = 4
            };
            var sortedDict = new System.Collections.Generic.SortedDictionary <int, int> {
                [1] = 2, [3] = 4
            };

            Assert.IsTrue(dict.Any());
            Assert.IsTrue(dict.Any(kv => kv.Key == 3));
            Assert.IsTrue(sortedDict.Any());
            Assert.IsTrue(sortedDict.Any(kv => kv.Key == 3));
        }
Esempio n. 2
0
        public void Errors_Dictionary()
        {
            var dict = new System.Collections.Generic.Dictionary <int, int> {
                [1] = 2, [3] = 4
            };
            var sortedDict = new System.Collections.Generic.SortedDictionary <int, int> {
                [1] = 2, [3] = 4
            };

            try { dict.Any(null); Assert.Fail(); } catch (ArgumentException exc) { Assert.AreEqual("predicate", exc.ParamName); }
            try { sortedDict.Any(null); Assert.Fail(); } catch (ArgumentException exc) { Assert.AreEqual("predicate", exc.ParamName); }
        }