From d42ebd7ea5869f81b0ec124c8a6a7606f92299b6 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 27 Aug 2019 11:13:06 -0400 Subject: [PATCH] added ExceptionAssert.Between method --- src/client/spark_core/utils/Exceptions/ExceptionAssert.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/client/spark_core/utils/Exceptions/ExceptionAssert.cs b/src/client/spark_core/utils/Exceptions/ExceptionAssert.cs index 05a86f42e..e61beb3fe 100644 --- a/src/client/spark_core/utils/Exceptions/ExceptionAssert.cs +++ b/src/client/spark_core/utils/Exceptions/ExceptionAssert.cs @@ -44,6 +44,11 @@ namespace mbts.utils { throw new ArgumentException($"Must equal {value}.", name); } + public static void Between(T argument, T minimum, T maximum, string name) where T : struct, IComparable { + if (argument.CompareTo(minimum) < 0 || argument.CompareTo(maximum) > 0) + throw new ArgumentException($"Must be between {minimum} and {maximum}, inclusive (actually {argument}).", name); + } + public static void GreaterThan(T argument, T value, string name) where T : IComparable { if (argument.CompareTo(value) <= 0) throw new ArgumentException($"Must be greater than {value}.", name);