Beispiel #1
0
 public static void Average_Long_Overflow(Labeled <ParallelQuery <int> > labeled, int count)
 {
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Select(x => x == 0 ? 1 : long.MaxValue).Average());
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Select(x => x == 0 ? (long?)1 : long.MaxValue).Average());
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Average(x => x == 0 ? -1 : long.MinValue));
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Average(x => x == 0 ? (long?)-1 : long.MinValue));
 }
Beispiel #2
0
 public static void Sum_Int_Overflow(Labeled <ParallelQuery <int> > labeled, int count, int sum)
 {
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Select(x => x == 0 ? int.MaxValue : x).Sum());
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Select(x => x == 0 ? int.MaxValue : (int?)x).Sum());
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Sum(x => x == 0 ? int.MinValue : -x));
     Functions.AssertThrowsWrapped <OverflowException>(() => labeled.Item.Sum(x => x == 0 ? int.MinValue : -(int?)x));
 }
        public static void ToDictionary_AggregateException(Labeled <ParallelQuery <int> > labeled, int count)
        {
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary((Func <int, int>)(x => { throw new DeliberateTestException(); })));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary((Func <int, int>)(x => { throw new DeliberateTestException(); }), y => y));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary(x => x, (Func <int, int>)(y => { throw new DeliberateTestException(); })));

            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary((Func <int, int>)(x => { throw new DeliberateTestException(); }), EqualityComparer <int> .Default));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary((Func <int, int>)(x => { throw new DeliberateTestException(); }), y => y, EqualityComparer <int> .Default));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary(x => x, (Func <int, int>)(y => { throw new DeliberateTestException(); }), EqualityComparer <int> .Default));

            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary(x => x, new FailingEqualityComparer <int>()));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.ToDictionary(x => x, y => y, new FailingEqualityComparer <int>()));
        }
Beispiel #4
0
 public static void Aggregate_AggregateException(Labeled <ParallelQuery <int> > labeled, int count)
 {
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate((i, j) => { throw new DeliberateTestException(); }));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate(0, (i, j) => { throw new DeliberateTestException(); }));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate(0, (i, j) => { throw new DeliberateTestException(); }, i => i));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate <int, int, int>(0, (i, j) => i, i => { throw new DeliberateTestException(); }));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate(0, (i, j) => { throw new DeliberateTestException(); }, (i, j) => i, i => i));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate <int, int, int>(0, (i, j) => i, (i, j) => i, i => { throw new DeliberateTestException(); }));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate <int, int, int>(() => { throw new DeliberateTestException(); }, (i, j) => i, (i, j) => i, i => i));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate(() => 0, (i, j) => { throw new DeliberateTestException(); }, (i, j) => i, i => i));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate <int, int, int>(() => 0, (i, j) => i, (i, j) => i, i => { throw new DeliberateTestException(); }));
     if (Environment.ProcessorCount >= 2)
     {
         Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate(0, (i, j) => i, (i, j) => { throw new DeliberateTestException(); }, i => i));
         Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Aggregate(() => 0, (i, j) => i, (i, j) => { throw new DeliberateTestException(); }, i => i));
     }
 }
Beispiel #5
0
        public static void Min_AggregateException(Labeled <ParallelQuery <int> > labeled, int count)
        {
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, int>)(x => { throw new DeliberateTestException(); })));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, int?>)(x => { throw new DeliberateTestException(); })));

            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, long>)(x => { throw new DeliberateTestException(); })));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, long?>)(x => { throw new DeliberateTestException(); })));

            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, float>)(x => { throw new DeliberateTestException(); })));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, float?>)(x => { throw new DeliberateTestException(); })));

            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, double>)(x => { throw new DeliberateTestException(); })));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, double?>)(x => { throw new DeliberateTestException(); })));

            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, decimal>)(x => { throw new DeliberateTestException(); })));
            Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Min((Func <int, decimal?>)(x => { throw new DeliberateTestException(); })));
        }
Beispiel #6
0
 public static void Any_AggregateException(Labeled <ParallelQuery <int> > labeled, int count)
 {
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Any(x => { throw new DeliberateTestException(); }));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Select((Func <int, int>)(x => { throw new DeliberateTestException(); })).Any());
 }
Beispiel #7
0
 public static void Contains_AggregateException(Labeled <ParallelQuery <int> > labeled, int count)
 {
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Contains(1, new FailingEqualityComparer <int>()));
 }
Beispiel #8
0
 public static void Cast_Assignable_InvalidCastException(Labeled <ParallelQuery <int> > labeled, int count)
 {
     Functions.AssertThrowsWrapped <InvalidCastException>(() => labeled.Item.Select(x => (Int32)x).Cast <Castable>().ForAll(x => {; }));
     Functions.AssertThrowsWrapped <InvalidCastException>(() => labeled.Item.Select(x => (Int32)x).Cast <Castable>().ToList());
 }
Beispiel #9
0
 public static void Last_AggregateException(Labeled <ParallelQuery <int> > labeled, int count)
 {
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.Last(x => { throw new DeliberateTestException(); }));
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => labeled.Item.LastOrDefault(x => { throw new DeliberateTestException(); }));
 }
Beispiel #10
0
 public static void Min_AggregateException_NotComparable(Labeled <ParallelQuery <int> > labeled, int count)
 {
     Functions.AssertThrowsWrapped <ArgumentException>(() => labeled.Item.Min(x => new NotComparable(x)));
 }
Beispiel #11
0
 public static void SequenceEqual_AggregateException(Labeled <ParallelQuery <int> > left, Labeled <ParallelQuery <int> > right, int count, int item)
 {
     Functions.AssertThrowsWrapped <DeliberateTestException>(() => left.Item.SequenceEqual(right.Item, new FailingEqualityComparer <int>()));
 }