public static bool Validate(PaymentScheduleOptions value) { Type enumType = value.GetType(); bool valid = Enum.IsDefined(enumType, value); return(valid); }
public PaymentCalculator(GetPaymentAmountInput input, double interestRate) { this.AskingPrice = input.AskingPrice; this.DownPayment = input.DownPayment; this.PaymentSchedule = input.PaymentSchedule; this.AmortizationPeriod = input.AmortizationPeriod; this.InterestRate = interestRate; // Make sure the incoming parameters make sense this.Validate(); }
public void TestInvalidLengths() { // Valid lengths of mortgages is >5 years and <25 PaymentScheduleOptions periodPerYear = PaymentScheduleOptions.monthly; Assert.False(ValidateValidMortgageLength.Validate(1 * (int)periodPerYear, periodPerYear)); Assert.False(ValidateValidMortgageLength.Validate(4 * (int)periodPerYear, periodPerYear)); Assert.False(ValidateValidMortgageLength.Validate(30 * (int)periodPerYear, periodPerYear)); periodPerYear = PaymentScheduleOptions.weekly; Assert.False(ValidateValidMortgageLength.Validate(1 * (int)periodPerYear, periodPerYear)); Assert.False(ValidateValidMortgageLength.Validate(4 * (int)periodPerYear, periodPerYear)); Assert.False(ValidateValidMortgageLength.Validate(30 * (int)periodPerYear, periodPerYear)); periodPerYear = PaymentScheduleOptions.biweekly; Assert.False(ValidateValidMortgageLength.Validate(1 * (int)periodPerYear, periodPerYear)); Assert.False(ValidateValidMortgageLength.Validate(4 * (int)periodPerYear, periodPerYear)); Assert.False(ValidateValidMortgageLength.Validate(30 * (int)periodPerYear, periodPerYear)); }
public static bool Validate(int amortizationPeriod, PaymentScheduleOptions paymentSchedule) { double years = amortizationPeriod / (double)paymentSchedule; return(years >= 5.0 && years <= 25.0); }