Example #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.AreEqual(2, dict.Count());
            Assert.AreEqual(2, dict.Count(x => x.Key < 4));
            Assert.AreEqual(2, dict.LongCount());
            Assert.AreEqual(2, dict.LongCount(x => x.Key < 4));
            Assert.AreEqual(2, sortedDict.Count());
            Assert.AreEqual(2, sortedDict.Count(x => x.Key < 4));
            Assert.AreEqual(2, sortedDict.LongCount());
            Assert.AreEqual(2, sortedDict.LongCount(x => x.Key < 4));
        }
Example #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.Count(null); Assert.Fail(); } catch (ArgumentNullException exc) { Assert.AreEqual("predicate", exc.ParamName); }
            try { dict.LongCount(null); Assert.Fail(); } catch (ArgumentNullException exc) { Assert.AreEqual("predicate", exc.ParamName); }
            try { sortedDict.Count(null); Assert.Fail(); } catch (ArgumentNullException exc) { Assert.AreEqual("predicate", exc.ParamName); }
            try { sortedDict.LongCount(null); Assert.Fail(); } catch (ArgumentNullException exc) { Assert.AreEqual("predicate", exc.ParamName); }
        }