Esempio n. 1
0
        public void GroupIf_NullGroupPredicate_ThrowsArgumentNullException()
        {
            IEnumerable <int>     collection     = Enumerable.Range(0, 10);
            Func <int, int, bool> groupPredicate = null;

            Assert.Throws <ArgumentNullException>(() => CollectionExtensions.GroupIf(collection, groupPredicate));
        }
Esempio n. 2
0
        public void GroupIf_NullCollection_ThrowsArgumentNullException()
        {
            IEnumerable <int>     collection     = null;
            Func <int, int, bool> groupPredicate = (i1, i2) => i2 == i1 + 1;

            Assert.Throws <ArgumentNullException>(() => CollectionExtensions.GroupIf(collection, groupPredicate));
        }
Esempio n. 3
0
        public void GroupIf_BasicRangeGrouping_ReturnsCorrectGrouping()
        {
            var input = new[]
            {
                1, 2, 3, 5, 6, 7, 9
            };

            var output = CollectionExtensions.GroupIf(input, (prev, current) => current == prev + 1).Select(group => $"{group.First()}-{group.Last()}").ToList();

            CollectionAssert.AreEqual(new[]
            {
                "1-3",
                "5-7",
                "9-9"
            }, output);
        }