public void WeightedAverage_IEnumerableToScalar_FloatProperty_SourceCumulativePercentageToOverflow_NotInfinityReturned() { IEnumerable <WeightedItem <float> > source = new WeightedItem <float>[] { new WeightedItem <float>(float.MaxValue, float.MaxValue), new WeightedItem <float>(float.MaxValue, float.MaxValue) }; var result = source.WeightedAverage(x => x.Value, x => x.Weight); float.IsPositiveInfinity(result).Should().BeFalse(); }
public void WeightedAverage_IEnumerableToScalar_DecimalProperty_SourceCumulativePercentageToOverflow_OverflowExceptionThrown() { IEnumerable <WeightedItem <decimal> > source = new WeightedItem <decimal>[] { new WeightedItem <decimal>(decimal.MaxValue, decimal.MaxValue), new WeightedItem <decimal>(decimal.MaxValue, decimal.MaxValue) }; Action comparison = () => { source.WeightedAverage(x => x.Value, x => x.Weight); }; comparison.ShouldThrow <OverflowException>(); }