public void AccumulateCompoundInterest_IEnumerableToIEnumberable_FloatProperty_SourceCumulativePercentageToOverflow_InfinityReturned() { IEnumerable <TimeSerie <float> > source = new TimeSerie <float>[] { new TimeSerie <float>(new DateTime(2012, 01, 01), 1) { GrowthRate = float.MaxValue }, new TimeSerie <float>(new DateTime(2012, 01, 01), 1) { GrowthRate = float.MaxValue } }; var result = source .OrderBy(x => x.ReferenceDate) .AccumulateCompoundInterest( x => x.GrowthRate, (x, cumProf) => new { Date = x.ReferenceDate, CumulativePercentage = cumProf }) .ToList(); float.IsPositiveInfinity(result[0].CumulativePercentage).Should().BeTrue(); }
public void AccumulateCompoundInterest_IEnumerableToIEnumberable_DecimalProperty_SourceCumulativePercentageToOverflow_OverflowExceptionThrown() { IEnumerable <TimeSerie <decimal> > source = new TimeSerie <decimal>[] { new TimeSerie <decimal>(new DateTime(2012, 01, 01), 1M) { GrowthRate = decimal.MaxValue }, new TimeSerie <decimal>(new DateTime(2012, 01, 01), 1M) { GrowthRate = decimal.MaxValue } }; Action comparison = () => { source .OrderBy(x => x.ReferenceDate) .AccumulateCompoundInterest( x => x.GrowthRate, (x, cumProf) => new { Date = x.ReferenceDate, CumulativePercentage = cumProf }) .ToList(); }; comparison.ShouldThrow <OverflowException>(); }
public void StandardDeviationOfFloat_SourceCumulativePercentageToOverflow_NotInfinityReturned() { IEnumerable <TimeSerie <float> > source = new TimeSerie <float>[] { new TimeSerie <float>(new DateTime(2012, 01, 01), float.MaxValue), new TimeSerie <float>(new DateTime(2012, 01, 01), float.MaxValue) }; var result = source .OrderBy(x => x.ReferenceDate) .StandardDeviation(x => x.Value); float.IsPositiveInfinity(result).Should().BeFalse(); }
public void VarianceOfDouble_SourceCumulativePercentageToOverflow_NotInfinityReturned() { IEnumerable <TimeSerie <double> > source = new TimeSerie <double>[] { new TimeSerie <double>(new DateTime(2012, 01, 01), double.MaxValue), new TimeSerie <double>(new DateTime(2012, 01, 01), double.MaxValue) }; var result = source .OrderBy(x => x.ReferenceDate) .Variance(x => x.Value); double.IsPositiveInfinity(result).Should().BeFalse(); }
public void StandardDeviationOfDecimal_SourceCumulativePercentageToOverflow_OverflowExceptionThrown() { IEnumerable <TimeSerie <decimal> > source = new TimeSerie <decimal>[] { new TimeSerie <decimal>(new DateTime(2012, 01, 01), decimal.MaxValue), new TimeSerie <decimal>(new DateTime(2012, 01, 01), decimal.MaxValue) }; Action comparison = () => { source .OrderBy(x => x.ReferenceDate) .StandardDeviation(x => x.Value); }; comparison.ShouldThrow <OverflowException>(); }
public void AccumulateCompoundInterest_IEnumerableToScalar_DoubleProperty_SourceCumulativePercentageToOverflow_NotInfinityReturned() { IEnumerable <TimeSerie <double> > source = new TimeSerie <double>[] { new TimeSerie <double>(new DateTime(2012, 01, 01), 1) { GrowthRate = double.MaxValue }, new TimeSerie <double>(new DateTime(2012, 01, 01), 1) { GrowthRate = double.MaxValue } }; var result = source .OrderBy(x => x.ReferenceDate) .AccumulateCompoundInterest(x => x.GrowthRate); double.IsPositiveInfinity(result).Should().BeTrue(); }