Beispiel #1
0
        public void Slice_FromStringExtensions_ReturnsCorrectValues()
        {
            this.RunSliceTestCases((from, to, step, length) =>
            {
                var source            = new string(Enumerable.Range(0, length).Select(i => (char)('a' + i)).ToArray());
                var sut               = StringExtensions.Slice(source, from, to, step);
                var expectedIndexList = SliceExpectedResultCalculator.Calculate(from, to, step, length);
                var expected          = new string(expectedIndexList.Select(i => (char)('a' + i)).ToArray());

                Assert.Equal(expected, sut);
            });
        }
Beispiel #2
0
        public void Slice_FromIndexedExtensions_ReturnsCorrectValues()
        {
            this.RunSliceTestCases((from, to, step, length) =>
            {
                var source   = Enumerable.Range(0, length).ToArray();
                var sut      = IndexedExtensions.Slice(source, from, to, step).ToArray();
                var expected = SliceExpectedResultCalculator.Calculate(from, to, step, length);

                Assert.True(
                    expected.SequenceEqual(sut),
                    ErrorFormatter.Format(sliceResultErrorFormat, source, from, to, step, expected, sut));
            });
        }
Beispiel #3
0
        public void Slice_FromEnumerableExtensions_GivenCollectionAsSource_ReturnsCorrectValues()
        {
            this.RunSliceTestCases((from, to, step, length) =>
            {
                var source   = new Queue <int>(Enumerable.Range(0, length));
                var sut      = EnumerableExtensions.Slice(source, from, to, step).ToArray();
                var expected = SliceExpectedResultCalculator.Calculate(from, to, step, length);

                LazyAssert.True(
                    expected.SequenceEqual(sut),
                    () => ErrorFormatter.Format(sliceResultErrorFormat, source, from, to, step, expected, sut));
            });
        }