Пример #1
0
        public void TestWindowedNegativeWindowSizeException()
        {
            var sequence = Enumerable.Repeat(1, 10);

            AssertThrowsArgument.OutOfRangeException("size", () =>
                                                     sequence.Windowed(-5));
        }
Пример #2
0
        public void TestNullSequenceException2()
        {
            const IEnumerable <int> sequence = null;

            AssertThrowsArgument.NullException("sequence", () =>
                                               sequence.Incremental((prev, next, i) => prev + next));
        }
Пример #3
0
        public void TestNegativeSubsetSize()
        {
            const int count    = 10;
            var       sequence = Enumerable.Range(1, count);

            AssertThrowsArgument.OutOfRangeException("subsetSize", () =>
                                                     sequence.Subsets(-5));
        }
Пример #4
0
        public void TestNegativeMaxValueException()
        {
            const int maxValue = -10;

            Assert.Less(maxValue, 0);

            AssertThrowsArgument.OutOfRangeException("maxValue", () =>
                                                     MoreEnumerable.Random(maxValue));
        }
Пример #5
0
        public void InsertWithIndexGreaterThanSourceLengthMaterialized(int count)
        {
            var source = Enumerable.Range(0, count).ToList();
            var result = source.Insert(new[] { 97, 98, 99 }, count + 1);

            AssertThrowsArgument.OutOfRangeException("index", () =>
                                                     result.ForEach((e, index) =>
                                                                    Assert.That(e, Is.EqualTo(source[index]))));
        }
Пример #6
0
        public void AssertCountNegativeCount()
        {
            var source = new object[0];

            AssertThrowsArgument.OutOfRangeException("count", () =>
                                                     source.AssertCount(-1));
            AssertThrowsArgument.OutOfRangeException("count", () =>
                                                     source.AssertCount(-1, BreakingFunc.Of <int, int, Exception>()));
        }
Пример #7
0
        public void TestMinValueGreaterThanMaxValueException()
        {
            const int minValue = 100;
            const int maxValue = 10;

            Assert.Greater(minValue, maxValue);

            AssertThrowsArgument.OutOfRangeException("minValue", () =>
                                                     MoreEnumerable.Random(minValue, maxValue));
        }
Пример #8
0
        public void TestRandomSubsetLongerThanSequence()
        {
            const int count      = 100;
            const int subsetSize = count + 5;
            var       sequence   = Enumerable.Range(1, count);

            AssertThrowsArgument.OutOfRangeException("subsetSize", () =>
            {
                sequence.RandomSubset(subsetSize).Consume();
            });
        }
Пример #9
0
        public void TestSubsetLargerThanSequence()
        {
            const int count    = 10;
            var       sequence = Enumerable.Range(1, count);
            var       result   = sequence.Subsets(count + 5);

            AssertThrowsArgument.OutOfRangeException("subsetSize", () =>
            {
                result.Consume(); // this particular exception is deferred until sequence evaluation
            });
        }
Пример #10
0
        public void InsertWithIndexGreaterThanSourceLengthMaterialized(int count)
        {
            var seq1 = Enumerable.Range(0, count).ToList();
            var seq2 = new[] { 97, 98, 99 };

            using var test1 = seq1.AsTestingSequence();
            using var test2 = seq2.AsTestingSequence();

            var result = test1.Insert(test2, count + 1);

            AssertThrowsArgument.OutOfRangeException("index", () =>
                                                     result.ForEach((e, index) =>
                                                                    Assert.That(e, Is.EqualTo(seq1[index]))));
        }
Пример #11
0
 public void CountBetweenWithMaxLesserThanMin()
 {
     AssertThrowsArgument.OutOfRangeException("max", () =>
                                              new[] { 1 }.CountBetween(1, 0));
 }
Пример #12
0
 public void TestLeadZeroOffset()
 {
     AssertThrowsArgument.OutOfRangeException("offset", () =>
                                              Enumerable.Range(1, 100).Lead(0, (val, leadVal) => val + leadVal));
 }
Пример #13
0
 public void InsertWithNegativeIndex()
 {
     AssertThrowsArgument.OutOfRangeException("index", () =>
                                              Enumerable.Range(1, 10).Insert(new[] { 97, 98, 99 }, -1));
 }
Пример #14
0
 public void BatchNegativeSize()
 {
     AssertThrowsArgument.OutOfRangeException("size", () =>
                                              new object[0].Batch(-1));
 }
Пример #15
0
 public void BatchZeroSize()
 {
     AssertThrowsArgument.OutOfRangeException("size", () =>
                                              new object[0].Batch(0));
 }
Пример #16
0
 public void TestExcludeNegativeCountException()
 {
     AssertThrowsArgument.OutOfRangeException("count", () =>
                                              Enumerable.Range(1, 10).Exclude(0, -5));
 }
Пример #17
0
 public void TakeEveryOutOfRangeZeroStep()
 {
     AssertThrowsArgument.OutOfRangeException("step", () =>
                                              new object[0].TakeEvery(0));
 }
Пример #18
0
 public void MoveWithNegativeToIndex()
 {
     AssertThrowsArgument.OutOfRangeException("toIndex", () =>
                                              new[] { 1 }.Move(0, 0, -1));
 }
Пример #19
0
 public void TestRandomSubsetNegativeSubsetSize2()
 {
     AssertThrowsArgument.OutOfRangeException("subsetSize", () =>
                                              Enumerable.Range(1, 10).RandomSubset(-1, new Random()));
 }
Пример #20
0
 public void TestNegativeRepeatCount()
 {
     AssertThrowsArgument.OutOfRangeException("count", () =>
                                              Enumerable.Range(1, 10).Repeat(-3));
 }
Пример #21
0
 public void ExactlyWithNegativeCount()
 {
     AssertThrowsArgument.OutOfRangeException("count", () =>
                                              new[] { 1 }.Exactly(-1));
 }
Пример #22
0
 public void PadStartWithSelectorWithNegativeWidth()
 {
     AssertThrowsArgument.Exception("width", () => new int[0].PadStart(-1, x => x));
 }
Пример #23
0
 public void PadStartWithPaddingWithNegativeWidth()
 {
     AssertThrowsArgument.Exception("width", () => new int[0].PadStart(-1, 1));
 }
Пример #24
0
 public void CountBetweenWithNegativeMax()
 {
     AssertThrowsArgument.OutOfRangeException("max", () =>
                                              new[] { 1 }.CountBetween(0, -1));
 }
Пример #25
0
 public void TestExcludeNegativeStartIndexException()
 {
     AssertThrowsArgument.OutOfRangeException("startIndex", () =>
                                              Enumerable.Range(1, 10).Exclude(-10, 10));
 }
Пример #26
0
 public void TakeEveryNegativeSkip()
 {
     AssertThrowsArgument.OutOfRangeException("step", () =>
                                              new object[0].TakeEvery(-1));
 }
Пример #27
0
 public void WindowLeftWithNegativeWindowSize()
 {
     AssertThrowsArgument.OutOfRangeException("size", () =>
                                              Enumerable.Repeat(1, 10).WindowLeft(-5));
 }
Пример #28
0
 public void MoveWithNegativeFromIndex()
 {
     AssertThrowsArgument.OutOfRangeException("fromIndex", () =>
                                              new[] { 1 }.Move(-1, 0, 0));
 }
Пример #29
0
 public void AtLeastWithNegativeCount()
 {
     AssertThrowsArgument.OutOfRangeException("count", () =>
                                              new[] { 1 }.AtLeast(-1));
 }
Пример #30
0
 public void MoveWithNegativeCount()
 {
     AssertThrowsArgument.OutOfRangeException("count", () =>
                                              new[] { 1 }.Move(0, -1, 0));
 }