Beispiel #1
0
        public void TestWindowedNegativeWindowSizeException()
        {
            var sequence = Enumerable.Repeat(1, 10);

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

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

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

            Assert.Less(maxValue, 0);

            AssertThrowsArgument.OutOfRangeException("maxValue", () =>
                                                     MoreEnumerable.Random(maxValue));
        }
Beispiel #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]))));
        }
Beispiel #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>()));
        }
Beispiel #7
0
        public void TestMinValueGreaterThanMaxValueException()
        {
            const int minValue = 100;
            const int maxValue = 10;

            Assert.Greater(minValue, maxValue);

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