예제 #1
0
        public void MultipleFloatFromSelector()
        {
            NameNum <float>[] source = new NameNum <float>[]
            {
                new NameNum <float> {
                    name = "Tim", num = 5.5f
                },
                new NameNum <float> {
                    name = "John", num = 15.5f
                },
                new NameNum <float> {
                    name = "Bob", num = 3.0f
                }
            };
            float expected = 8.0f;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #2
0
        public void NullableFloatFromSelector()
        {
            NameNum <float?>[] source = new NameNum <float?>[]
            {
                new NameNum <float?> {
                    name = "Tim", num = 5.5f
                },
                new NameNum <float?> {
                    name = "John", num = 15.5f
                },
                new NameNum <float?> {
                    name = "Bob", num = null
                }
            };
            float?expected = 10.5f;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #3
0
        public void MultipleDecimalFromSelector()
        {
            NameNum <decimal>[] source = new NameNum <decimal>[]
            {
                new NameNum <decimal> {
                    name = "Tim", num = 5.5m
                },
                new NameNum <decimal> {
                    name = "John", num = 15.5m
                },
                new NameNum <decimal> {
                    name = "Bob", num = 3.0m
                }
            };
            decimal expected = 8.0m;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #4
0
        public void NullableDecimalFromSelector()
        {
            NameNum <decimal?>[] source = new NameNum <decimal?>[]
            {
                new NameNum <decimal?> {
                    name = "Tim", num = 5.5m
                },
                new NameNum <decimal?> {
                    name = "John", num = 15.5m
                },
                new NameNum <decimal?> {
                    name = "Bob", num = null
                }
            };
            decimal?expected = 10.5m;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #5
0
        public void MultipleDoubleFromSelector()
        {
            NameNum <double>[] source = new NameNum <double>[]
            {
                new NameNum <double> {
                    name = "Tim", num = 5.5
                },
                new NameNum <double> {
                    name = "John", num = 15.5
                },
                new NameNum <double> {
                    name = "Bob", num = 3.0
                }
            };
            double expected = 8.0;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #6
0
        public void NullableLongFromSelector()
        {
            NameNum <long?>[] source = new NameNum <long?>[]
            {
                new NameNum <long?> {
                    name = "Tim", num = 40L
                },
                new NameNum <long?> {
                    name = "John", num = null
                },
                new NameNum <long?> {
                    name = "Bob", num = 30L
                }
            };
            double?expected = 35;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #7
0
        public void MultipleLongFromSelector()
        {
            NameNum <long>[] source = new NameNum <long>[]
            {
                new NameNum <long> {
                    name = "Tim", num = 40L
                },
                new NameNum <long> {
                    name = "John", num = 50L
                },
                new NameNum <long> {
                    name = "Bob", num = 60L
                }
            };
            double expected = 50;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #8
0
        public void NullableIntFromSelector()
        {
            NameNum <int?>[] source = new NameNum <int?>[]
            {
                new NameNum <int?> {
                    name = "Tim", num = 10
                },
                new NameNum <int?> {
                    name = "John", num = null
                },
                new NameNum <int?> {
                    name = "Bob", num = 10
                }
            };
            double?expected = 10;

            Assert.Equal(expected, source.Average(e => e.num));
        }
예제 #9
0
        public void MultipleIntFromSelector()
        {
            NameNum <int>[] source = new NameNum <int>[]
            {
                new NameNum <int> {
                    name = "Tim", num = 10
                },
                new NameNum <int> {
                    name = "John", num = -10
                },
                new NameNum <int> {
                    name = "Bob", num = 15
                }
            };
            double expected = 5;

            Assert.Equal(expected, source.Average(e => e.num));
        }