public void NullableFloat_WithSelector() { 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.Average(e => e.num)); }
public void NullableDecimal_WithSelector() { 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.Average(e => e.num)); }
public void Float_WithSelector() { 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.Average(e => e.num)); }
public void NullableDouble_WithSelector() { var source = new[] { new{ name = "Tim", num = (double?)5.5 }, new{ name = "John", num = (double?)15.5 }, new{ name = "Bob", num = default(double?) } }; double? expected = 10.5; Assert.Equal(expected, source.Average(e => e.num)); }
public void Decimal_WithSelector() { 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.Average(e => e.num)); }
public void Double_WithSelector() { var source = new [] { new { name = "Tim", num = 5.5}, new { name = "John", num = 15.5}, new { name = "Bob", num = 3.0} }; double expected = 8.0; Assert.Equal(expected, source.Average(e => e.num)); }
public void NullableLong_WithSelector() { 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.Average(e => e.num)); }
public void Long_FromSelector() { 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.Average(e => e.num)); }
public void NullableInt_WithSelector() { 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.Average(e => e.num)); }
public void Int_WithSelector() { 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.Average(e => e.num)); }