Ejemplo n.º 1
0
        public static void Average_Long(Labeled <ParallelQuery <int> > labeled, int count, double average)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.Equal(average, query.Select(x => (long)x).Average());
            Assert.Equal((double?)average, query.Select(x => (long?)x).Average());
            Assert.Equal(-average, query.Average(x => - (long)x));
            Assert.Equal(-(double?)average, query.Average(x => - (long?)x));
        }
Ejemplo n.º 2
0
        public static void Average_Decimal(Labeled <ParallelQuery <int> > labeled, int count, decimal average)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.Equal(average, query.Select(x => (decimal)x).Average());
            Assert.Equal((decimal?)average, query.Select(x => (decimal?)x).Average());
            Assert.Equal(-average, query.Average(x => - (decimal)x));
            Assert.Equal(-(decimal?)average, query.Average(x => - (decimal?)x));
        }
Ejemplo n.º 3
0
        public static void Average_Float(Labeled <ParallelQuery <int> > labeled, int count, float average)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.Equal(average, query.Select(x => (float)x).Average());
            Assert.Equal((float?)average, query.Select(x => (float?)x).Average());
            Assert.Equal(-average, query.Average(x => - (float)x));
            Assert.Equal(-(float?)average, query.Average(x => - (float?)x));
        }
Ejemplo n.º 4
0
        public static void Average_Long_SomeNull(Labeled <ParallelQuery <int> > labeled, int count, double average)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.Equal(Math.Truncate(average), query.Select(x => (x % 2 == 0) ? (long?)x : null).Average());
            Assert.Equal(Math.Truncate(-average), query.Average(x => (x % 2 == 0) ? -(long?)x : null));
        }
Ejemplo n.º 5
0
        public static void Average_Int_AllNull(Labeled <ParallelQuery <int> > labeled, int count, double average)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.Null(query.Select(x => (int?)null).Average());
            Assert.Null(query.Average(x => (int?)null));
        }
Ejemplo n.º 6
0
        public static void Average_Decimal_AllNull(Labeled <ParallelQuery <int> > labeled, int count, decimal average)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.Null(query.Select(x => (decimal?)null).Average());
            Assert.Null(query.Average(x => (decimal?)null));
        }
Ejemplo n.º 7
0
        public static void Average_Float_SomeNull(Labeled <ParallelQuery <int> > labeled, int count, float average)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.Equal((float?)Math.Truncate(average), query.Select(x => (x % 2 == 0) ? (float?)x : null).Average());
            Assert.Equal((float?)Math.Truncate(-average), query.Average(x => (x % 2 == 0) ? -(float?)x : null));
        }