Exemple #1
0
        public void EqualRange_EmptyList(int value)
        {
            IReadOnlyList <Tuple <int> > list = new List <Tuple <int> >();

            var range = CollectionExtensions.EqualRange(
                list, value, Compare);

            Assert.Equal(Enumerable.Empty <Tuple <int> >(), range);
        }
Exemple #2
0
        [InlineData(1, -1, typeof(ArgumentOutOfRangeException))] // Negative count.
        public void EqualRange_Preconditions(int index, int count, Type expectedException)
        {
            IReadOnlyList <string> list = new List <string> {
                "10", "11", "12"
            };

            Assert.Throws(
                expectedException,
                () => CollectionExtensions.EqualRange(
                    list, index, count, "10", string.Compare));
        }
Exemple #3
0
        public void EqualRange_FullRange(int value, int skip, int take)
        {
            IReadOnlyList <Tuple <int, int> > list = new List <Tuple <int, int> > {
                Tuple.Create(11, 0),
                Tuple.Create(13, 1),
                Tuple.Create(13, 2),
                Tuple.Create(13, 3),
                Tuple.Create(15, 4)
            };

            var range = CollectionExtensions.EqualRange(
                list, value, (l, r) => l.Item1.CompareTo(r));

            Assert.Equal(list.Skip(skip).Take(take), range);
        }