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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
public void ReturnsExpectedValuesIndexed_True() { int[] source = new[] { 1, 2, 3, 4, 5 }; Assert.Equal(source, source.AsQueryable().Where((e, i) => true)); }
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)); }
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)); }
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)); }
public void ReturnsExpectedValuesIndexed_False() { int[] source = new[] { 1, 2, 3, 4, 5 }; Assert.Empty(source.AsQueryable().Where((e, i) => false)); }
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)); }
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)); }