Example #1
0
 public void SelectPropertyUsingIndex()
 {
     var source = new[]{
         new { name="Prakash", custID=98088 },
         new { name="Bob", custID=29099 },
         new { name="Chris", custID=39033 }
     };
     string[] expected = { "Prakash", null, null };
     Assert.Equal(expected, source.AsQueryable().Select((e, i) => i == 0 ? e.name : null));
 }
Example #2
0
        public void NullableFloatFromSelector()
        {
            var source = new []
            {
                new { name = "Tim", num = (float?)5.5f },
                new { name = "John", num = (float?)15.5f },
                new { name = "Bob", num = default(float?) }
            };
            float? expected = 10.5f;

            Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
        }
Example #3
0
 public void SelectProperty()
 {
     var source = new []{
         new { name="Prakash", custID=98088 },
         new { name="Bob", custID=29099 },
         new { name="Chris", custID=39033 },
         new { name=(string)null, custID=30349 },
         new { name="Prakash", custID=39030 }
     };
     string[] expected = { "Prakash", "Bob", "Chris", null, "Prakash" };
     Assert.Equal(expected, source.AsQueryable().Select(e => e.name));
 }
Example #4
0
 public void MinStringWitSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=100.45m },
         new { name="John", num=10.5m },
         new { name="Bob", num=0.05m }
     };
     Assert.Equal("Bob", source.AsQueryable().Min(e => e.name));
 }
Example #5
0
 public void MinNullableDoubleWithSelectorAccessingProperty()
 {
     var source = new[] {
         new { name="Tim", num=(double?)-45.5 },
         new { name="John", num=(double?)-132.5 },
         new { name="Bob", num=default(double?) }
     };
     Assert.Equal(-132.5, source.AsQueryable().Min(e => e.num));
 }
Example #6
0
 public void MinNullableDecimalWithSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=(decimal?)100.45m },
         new { name="John", num=(decimal?)10.5m },
         new { name="Bob", num=default(decimal?) }
     };
     Assert.Equal(10.5m, source.AsQueryable().Min(e => e.num));
 }
Example #7
0
 public void MaxInt64WithSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=10L },
         new { name="John", num=-105L },
         new { name="Bob", num=long.MaxValue }
     };
     Assert.Equal(long.MaxValue, source.AsQueryable().Max(e => e.num));
 }
Example #8
0
 public void MinNullableInt64WithSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=default(long?) },
         new { name="John", num=(long?)long.MinValue },
         new { name="Bob", num=(long?)-10L }
     };
     Assert.Equal(long.MinValue, source.AsQueryable().Min(e => e.num));
 }
Example #9
0
        public void NullableLongFromSelector()
        {
            var source = new []
            {
                new { name = "Tim", num = (long?)40L },
                new { name = "John", num = default(long?) },
                new { name = "Bob", num = (long?)30L }
            };
            double? expected = 35;

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

            Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
        }
Example #11
0
 public void MaxNullableDoubleWithSelectorAccessingProperty()
 {
     var source = new []{
         new { name = "Tim", num = (double?)40.5},
         new { name = "John", num = default(double?)},
         new { name = "Bob", num = (double?)100.45}
     };
     Assert.Equal(100.45, source.AsQueryable().Max(e => e.num));
 }
Example #12
0
 public void MaxStringWithSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=420.5m },
         new { name="John", num=900.25m },
         new { name="Bob", num=10.45m }
     };
     Assert.Equal("Tim", source.AsQueryable().Max(e => e.name));
 }
Example #13
0
 public void MaxNullableInt64WithSelectorAccessingField()
 {
     var source = new[]{
         new {name="Tim", num=default(long?) },
         new {name="John", num=(long?)-105L },
         new {name="Bob", num=(long?)long.MaxValue }
     };
     Assert.Equal(long.MaxValue, source.AsQueryable().Max(e => e.num));
 }
Example #14
0
 public void MaxNullableSingleWithSelectorAccessingProperty()
 {
     var source = new[]
     {
         new { name="Tim", num=(float?)40.5f },
         new { name="John", num=(float?)null },
         new { name="Bob", num=(float?)100.45f }
     };
     Assert.Equal(100.45f, source.AsQueryable().Max(e => e.num));
 }
Example #15
0
        public void MaxNullableInt32WithSelectorAccessingField()
        {
            var source = new[]{
                new { name="Tim", num=(int?)10 },
                new { name="John", num=(int?)-105 },
                new { name="Bob", num=(int?)null }
            };

            Assert.Equal(10, source.AsQueryable().Max(e => e.num));
        }
Example #16
0
 public void MaxDoubleWithSelectorAccessingField()
 {
     var source = new[]{
         new { name="Tim", num=40.5 },
         new { name="John", num=-10.25 },
         new { name="Bob", num=100.45 }
     };
     Assert.Equal(100.45, source.AsQueryable().Max(e => e.num));
 }
Example #17
0
        public void MaxSingleWithSelectorAccessingProperty()
        {
            var source = new []
            {
                new { name = "Tim", num = 40.5f },
                new { name = "John", num = -10.25f },
                new { name = "Bob", num = 100.45f }
            };

            Assert.Equal(100.45f, source.AsQueryable().Max(e => e.num));
        }
Example #18
0
        public void NullableIntFromSelector()
        {
            var source = new []
            {
                new { name = "Tim", num  = (int?)10 },
                new { name = "John", num =  default(int?) },
                new { name = "Bob", num = (int?)10 }
            };
            double? expected = 10;

            Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
        }
Example #19
0
        public void MultipleFloatFromSelector()
        {
            var source = new[]
            {
                new{ name = "Tim", num = 5.5f},
                new{ name = "John", num = 15.5f},
                new{ name = "Bob", num = 3.0f}
            };
            float expected = 8.0f;

            Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
        }
Example #20
0
        public void MultipleLongFromSelector()
        {
            var source = new []
            {
                new { name = "Tim", num = 40L },
                new { name = "John", num = 50L },
                new { name = "Bob", num = 60L }
            };
            double expected = 50;

            Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
        }
Example #21
0
 public void ReturnsExpectedValuesIndexed_True()
 {
     int[] source = new[] { 1, 2, 3, 4, 5 };
     Assert.Equal(source, source.AsQueryable().Where((e, i) => true));
 }
Example #22
0
        public void MultipleDecimalFromSelector()
        {
            var source = new[]
            {
                new{ name = "Tim", num = 5.5m},
                new{ name = "John", num = 15.5m},
                new{ name = "Bob", num = 3.0m}
            };
            decimal expected = 8.0m;

            Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
        }
Example #23
0
 public void MinNullableInt32WithSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=(int?)10 },
         new { name="John", num=default(int?) },
         new { name="Bob", num=(int?)-30 }
     };
     Assert.Equal(-30, source.AsQueryable().Min(e => e.num));
 }
Example #24
0
 public void MinInt32WithSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=10 },
         new { name="John", num=-105 },
         new { name="Bob", num=-30 }
     };
     Assert.Equal(-105, source.AsQueryable().Min(e => e.num));
 }
Example #25
0
 public void ReturnsExpectedValuesIndexed_False()
 {
     int[] source = new[] { 1, 2, 3, 4, 5 };
     Assert.Empty(source.AsQueryable().Where((e, i) => false));
 }
Example #26
0
        public void MultipleIntFromSelector()
        {
            var source = new []
            {
                new { name="Tim", num = 10 },
                new { name="John", num = -10 },
                new { name="Bob", num = 15 }
            };
            double expected = 5;

            Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
        }
Example #27
0
 public void MinDoubleWithSelectorAccessingProperty()
 {
     var source = new[]{
         new { name="Tim", num=-45.5 },
         new { name="John", num=-132.5 },
         new { name="Bob", num=20.45 }
     };
     Assert.Equal(-132.5, source.AsQueryable().Min(e => e.num));
 }