public NumericRounding(decimal step, Rounding.RoundingStyle style) : base(step.ToString(NumberFormatInfo.InvariantInfo), style) { if (step <= 0) { throw new ArgumentException("The parameter '{0}' must be a value greater than zero.", "step"); } this.step = step; }
public DateTimeRounding(TimeSpan step, Rounding.RoundingStyle style) : base(step.ToString(), style) { if (step.Ticks <= 0) { throw new ArgumentException("The parameter 'step' must be a value greater than zero.", "step"); } if (step.TotalDays > 1) { throw new ArgumentException("The parameter 'step' must be less or equal to one day", "step"); } this.step = step; }
public void GetValue_ValueQuarterHourRoundingStyle_NewValue(DateTime value, Rounding.RoundingStyle roundingStyle, DateTime newValue) { var rounder = new DateTimeRounding(new TimeSpan(0, 0, 15, 0), roundingStyle); Assert.That(rounder.GetValue(value), Is.EqualTo(newValue)); }
public void GetValue_ValueStepStyle_NewValue(decimal value, double step, Rounding.RoundingStyle roundingStyle, decimal newValue) { var rounder = new NumericRounding(step, roundingStyle); Assert.That(rounder.GetValue(value), Is.EqualTo(newValue)); }