public void Test_ShouldVerify_Success() { // Assets VerificationResultDto verificationResult = new VerificationResultDto(); int loanId = 123456; _loanServiceMock .Setup(x => x.Verify(loanId)) .Returns(verificationResult); // Action var result = Controller.Verify(loanId); // Assert _loanServiceMock.Verify(x => x.Verify(loanId), Times.Once); result.Should().NotBeNull(); }
public VerificationResultDto Verify(Loan loan) { VerificationTestDto arpTestObject = new VerificationTestDto { Name = $"Test ARP Amount for {loan.Address.State} located loan #{loan.Id}", Status = LoanVerificationResultCode.Success }; VerificationResultDto result = new VerificationResultDto(); // Run test only if MaximumLoanAmount 750,000 and Loan type is Conventional if (loan.LoanAmount >= MaximumLoanAmount && loan.LoanType == LoanType.Conventional) { if (loan.Address.IsPrimaryOccupancy) { // check loan ARP if (loan.ARP > 6) { // Error arpTestObject.Status |= LoanVerificationResultCode.ArpIsExceedRates; arpTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanArpRateIsInvalid, Constants.ErrorPayloadType.Loan.LoanArpRateIsInvalidMsg)); } } if (!loan.Address.IsPrimaryOccupancy) { // check loan ARP if (loan.ARP > 8) { // ARP Amount Error arpTestObject.Status |= LoanVerificationResultCode.ArpIsExceedRates; arpTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanArpRateIsInvalid, Constants.ErrorPayloadType.Loan.LoanArpRateIsInvalidMsg)); } } } result.Tests.Add(arpTestObject); return(result); }
public VerificationResultDto Verify(Loan loan) { VerificationTestDto arpTestObject = new VerificationTestDto { Name = $"Test ARP Amount for {loan.Address.State} located loan #{loan.Id}", Status = LoanVerificationResultCode.Success }; VerificationTestDto feeTestObject = new VerificationTestDto { Name = $"Test Fee Amount for {loan.Address.State} located loan #{loan.Id}", Status = LoanVerificationResultCode.Success }; VerificationResultDto result = new VerificationResultDto(); // Run test only if MaximumLoanAmount 400.000 and Loan type is Conventional or FHA or VA if (loan.LoanAmount >= MaximumLoanAmount && (loan.LoanType == LoanType.Conventional || loan.LoanType == LoanType.FHA || loan.LoanType == LoanType.VA)) { // check loan ARP (All Loans: 4%) if (loan.ARP > 4) { // Error arpTestObject.Status |= LoanVerificationResultCode.ArpIsExceedRates; arpTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanArpRateIsInvalid, Constants.ErrorPayloadType.Loan.LoanArpRateIsInvalidMsg)); } result.Tests.Add(arpTestObject); #region #Check fee // Loan amount <= 20,000: 6% // if > 20,000 and <= 75,000: 8%; // if > 75,000 and <= 150,000: 9 %; // if > 150,000: 10 % if (loan.FeesIncludedInTotal.Intersect(feesIncludedInTotal).Count() == 2) { bool isPassed = true; if (loan.LoanAmount <= 20.000 && loan.Fee > 6) { isPassed = false; } if (loan.LoanAmount > 20.000 && loan.LoanAmount <= 75.000 && loan.Fee > 8) { isPassed = false; } if (loan.LoanAmount > 75.000 && loan.LoanAmount <= 150.000 && loan.Fee > 9) { isPassed = false; } if (loan.LoanAmount > 150.000 && loan.Fee > 10) { isPassed = false; } if (!isPassed) { // Error feeTestObject.Status |= LoanVerificationResultCode.TotalFeesExceedTheAmount; feeTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanTotalFeesInvalid, Constants.ErrorPayloadType.Loan.LoanTotalFeesInvalidMsg)); } } result.Tests.Add(feeTestObject); #endregion //check fee } return(result); }
public VerificationResultDto Verify(Loan loan) { VerificationTestDto arpTestObject = new VerificationTestDto { Name = $"Test ARP Amount for {loan.Address.State} located loan #{loan.Id}", Status = LoanVerificationResultCode.Success }; VerificationTestDto feeTestObject = new VerificationTestDto { Name = $"Test Fee Amount for {loan.Address.State} located loan #{loan.Id}", Status = LoanVerificationResultCode.Success }; VerificationResultDto result = new VerificationResultDto(); // Run test only if MaximumLoanAmount 600.000 and Loan type is Conventional or FHA or VA if (loan.LoanAmount >= MaximumLoanAmount && (loan.LoanType == LoanType.Conventional || loan.LoanType == LoanType.FHA || loan.LoanType == LoanType.VA)) { #region # Check Arp if (loan.Address.IsPrimaryOccupancy && (loan.LoanType == LoanType.Conventional || loan.LoanType == LoanType.FHA)) { // check loan ARP if (loan.ARP > 5) { // ARP Amount Error arpTestObject.Status |= LoanVerificationResultCode.ArpIsExceedRates; arpTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanArpRateIsInvalid, Constants.ErrorPayloadType.Loan.LoanArpRateIsInvalidMsg)); } } if (!loan.Address.IsPrimaryOccupancy && loan.LoanType == LoanType.VA) { // check loan ARP if (loan.ARP > 3) { // ARP Amount Error arpTestObject.Status |= LoanVerificationResultCode.ArpIsExceedRates; arpTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanArpRateIsInvalid, Constants.ErrorPayloadType.Loan.LoanArpRateIsInvalidMsg)); } } #endregion //Check Arp // Add test results for ARP result.Tests.Add(arpTestObject); #region #Check fee // Loan amount <= 50,000: 3%; if >50,000 and <= 150,000: 4%; if > 150,000: 5 % if (loan.FeesIncludedInTotal.Intersect(feesIncludedInTotal).Count() == 2) { bool isPassed = true; if (loan.LoanAmount <= 50.000 && loan.Fee > 3) { isPassed = false; } if (loan.LoanAmount <= 150.000 && loan.Fee > 4) { isPassed = false; } if (loan.LoanAmount > 150.000 && loan.Fee > 5) { isPassed = false; } if (!isPassed) { // Error feeTestObject.Status |= LoanVerificationResultCode.TotalFeesExceedTheAmount; feeTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanTotalFeesInvalid, Constants.ErrorPayloadType.Loan.LoanTotalFeesInvalidMsg)); } } #endregion //check fee // Add test results for Fee result.Tests.Add(feeTestObject); } return(result); }
public VerificationResultDto Verify(Loan loan) { VerificationTestDto arpTestObject = new VerificationTestDto { Name = $"Test ARP Amount for {loan.Address.State} located loan #{loan.Id}", Status = LoanVerificationResultCode.Success }; VerificationTestDto feeTestObject = new VerificationTestDto { Name = $"Test Fee Amount for {loan.Address.State} located loan #{loan.Id}", Status = LoanVerificationResultCode.Success }; VerificationResultDto result = new VerificationResultDto(); // Run test only if Loan type is Conventional or FHA or VA if (loan.LoanType == LoanType.Conventional || loan.LoanType == LoanType.FHA || loan.LoanType == LoanType.VA) { #region # Check Arp if (loan.Address.IsPrimaryOccupancy && loan.LoanType == LoanType.VA) { // check loan ARP if (loan.ARP > 5) { // ARP Amount Error arpTestObject.Status |= LoanVerificationResultCode.ArpIsExceedRates; arpTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanArpRateIsInvalid, Constants.ErrorPayloadType.Loan.LoanArpRateIsInvalidMsg)); } } if (!loan.Address.IsPrimaryOccupancy && loan.LoanType == LoanType.VA) { // check loan ARP if (loan.ARP > 8) { // ARP Amount Error arpTestObject.Status |= LoanVerificationResultCode.ArpIsExceedRates; arpTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanArpRateIsInvalid, Constants.ErrorPayloadType.Loan.LoanArpRateIsInvalidMsg)); } } #endregion //Check Arp // Add test results for ARP result.Tests.Add(arpTestObject); // Check loan Fee if (loan.FeesIncludedInTotal.Intersect(feesIncludedInTotal).Count() == 3) { if (loan.Fee > MaximumPercentThatCanBeCharged) { // Error feeTestObject.Status |= LoanVerificationResultCode.TotalFeesExceedTheAmount; feeTestObject.Errors.Add(new VerificationErrorDto(ErrorCode.LoanTotalFeesInvalid, Constants.ErrorPayloadType.Loan.LoanTotalFeesInvalidMsg)); } // Add test results for Fee result.Tests.Add(feeTestObject); } } return(result); }