public void Inclusive_Value_Not_Between_Start_And_End_Returns_False() { decimal start = 1; decimal end = 5; decimal value = 0; Assert.IsFalse(value.Between(start, end, true)); Assert.IsFalse(value.Between(start, end)); }
public void Inclusive_Value_Equals_End_Returns_True() { decimal start = 1; decimal end = 5; decimal value = 5; Assert.IsTrue(value.Between(start, end, true)); Assert.IsTrue(value.Between(start, end)); }
/// <summary> /// Verifica se o valor está em uma variação percentual de tolerância a partir de um valor base /// </summary> /// <param name="origem">Valor a verificar</param> /// <param name="valorBase">Base de valor a aplicar o percentual de variação</param> /// <param name="percentual">Percentual de variação</param> public static bool IsInTolerance(this decimal origem, decimal valorBase, decimal percentual) { var absPercent = Math.Abs(percentual); var min = valorBase.Percent(absPercent * -1); var max = valorBase.Percent(absPercent); return(origem.Between(min, max)); }
public void Exclusive_Value_Equals_End_Returns_False() { decimal start = 1; decimal end = 5; decimal value = 5; Assert.IsFalse(value.Between(start, end, false)); }
public static void SetValue(this NumericUpDown nud, decimal number) { nud.Value = number.Between(nud.Minimum, nud.Maximum); }
public static decimal BetweenOrDefault(this decimal num, decimal lower, decimal upper, bool inclusive = false) { return(num.Between(lower, upper, inclusive) ? num : default(decimal)); }
public static bool InRange(this decimal current, decimal start, decimal end) { return(current.Between(start, end)); }
public void Test07_IsNotBetweenInverted() { decimal value = 7; Assert.AreEqual(false, value.Between(2, 1)); }
public void Test06_IsNotBetween() { decimal value = -7; Assert.AreEqual(false, value.Between(1, 2)); }
public static decimal IncrementBid(decimal amount) { if (amount.Between(0, 10)) { return(amount + 1); } if (amount.Between(10, 20)) { return(amount + 2); } if (amount.Between(20, 40)) { return(amount + 5); } if (amount.Between(40, 100)) { return(amount + 10); } if (amount.Between(100, 200)) { return(amount + 20); } if (amount.Between(200, 400)) { return(amount + 50); } if (amount.Between(400, 1000)) { return(amount + 100); } if (amount.Between(1000, 2000)) { return(amount + 200); } if (amount.Between(2000, 4000)) { return(amount + 500); } if (amount.Between(4000, 10000)) { return(amount + 1000); } if (amount.Between(10000, 20000)) { return(amount + 2000); } if (amount.Between(20000, 40000)) { return(amount + 4000); } if (amount.Between(40000, 100000)) { return(amount + 10000); } if (amount.Between(100000, 200000)) { return(amount + 20000); } if (amount.Between(200000, 400000)) { return(amount + 50000); } if (amount.Between(400000, 1000000000)) { return(amount + 100000); } if (amount.Between(1000000000, 2000000000)) { return(amount + 200000); } if (amount.Between(2000000000, 4000000000)) { return(amount + 400000); } return(amount + 500000); }