using System.Diagnostics; using NzbDrone.Common.EnsureThat.Resources; using NzbDrone.Common.Extensions; namespace NzbDrone.Common.EnsureThat { public static class EnsureDecimalExtensions { [DebuggerStepThrough] public static Param IsLt(this Param param, decimal limit) { if (param.Value >= limit) throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLt.Inject(param.Value, limit)); return param; } [DebuggerStepThrough] public static Param IsLte(this Param param, decimal limit) { if (!(param.Value <= limit)) throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotLte.Inject(param.Value, limit)); return param; } [DebuggerStepThrough] public static Param IsGt(this Param param, decimal limit) { if (param.Value <= limit) throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, limit)); return param; } [DebuggerStepThrough] public static Param IsGte(this Param param, decimal limit) { if (!(param.Value >= limit)) throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGte.Inject(param.Value, limit)); return param; } [DebuggerStepThrough] public static Param IsInRange(this Param param, decimal min, decimal max) { if (param.Value < min) throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToLow.Inject(param.Value, min)); if (param.Value > max) throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotInRange_ToHigh.Inject(param.Value, max)); return param; } } }