public void RandomNext() { var random = ExtraEnumerable.Random(1, 3).Take(50).ToArray(); Assert.Equal(50, random.Length); Assert.True(random.All(n => n >= 1 && n <= 2)); }
public void RandomMinIsGreaterThanMax() { Assert.Throws <ArgumentOutOfRangeException>(() => ExtraEnumerable.Random(5, 4)); }
public void AverageNullableInt() { var source = Enumerable.Range(0, 4500).Select(x => (int?)x).Concat(new int?[] { null, null, null }).Shuffle().ToArray(); Assert.AreEqual(Enumerable.Average(source), ExtraEnumerable.Average(source)); }
public void RandomMaxIsNegative() { Assert.Throws <ArgumentOutOfRangeException>(() => ExtraEnumerable.Random(-3)); }
public void AverageInt() { var source = Enumerable.Range(-100, 450).ToArray(); Assert.AreEqual(Enumerable.Average(source), ExtraEnumerable.Average(source)); }
public void AverageUInt() { var source = Enumerable.Range(0, 4500).ToArray(); Assert.AreEqual(Enumerable.Average(source), ExtraEnumerable.Average(source.Select(x => (uint)x).ToArray())); }
public long MaxByExtraLinq() => ExtraEnumerable.MaxBy(_data, i => i);
public bool ExactlyExtraLinq() => ExtraEnumerable.Exactly(_source, 500);
public long SumListExtraLinq() => ExtraEnumerable.Sum(_dataList);
public double AverageArrayExtraLinq() => ExtraEnumerable.Average(_data);
public long SumArrayExtraLinq() => ExtraEnumerable.Sum(_data);
public void RandomMinIsGreaterThanMax() { var _ = ExtraEnumerable.Random(5, 4); }
public void RandomMaxIsNegative() { var _ = ExtraEnumerable.Random(-3); }