public void SaveLoan_UpdateLoan_Person_NoGuarantor() { DynamicMock mockInstalmentManager = new DynamicMock(typeof(InstallmentManager)); DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); Loan loan = new Loan { Id = 1, Amount = 11, Code = "Test", InterestRate = 1, NbOfInstallments = 2, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), GracePeriod = 2, StartDate = new DateTime(2009, 1, 1), FundingLine = new FundingLine { Currency = new Currency { Code = "Code", Name = "Name" } }, LoanOfficer = new User(), Product = new LoanProduct { Currency = new Currency { Code = "Code", Name = "Name" } }, InstallmentList = new List<Installment> { _installment1, _installment2 }, Guarantors = new List<Guarantor>() }; EntryFee prodEntryFee = new EntryFee(); prodEntryFee.Value = 2; prodEntryFee.Id = 21; prodEntryFee.Name = "Tested"; LoanEntryFee loanEntryFee = new LoanEntryFee(); loanEntryFee.FeeValue = 2; loanEntryFee.ProductEntryFee = prodEntryFee; loanEntryFee.ProductEntryFeeId = 21; loan.LoanEntryFeesList = new List<LoanEntryFee>(); loan.LoanEntryFeesList.Add(loanEntryFee); IClient person = new Person { Active = false }; mockInstalmentManager.Expect("DeleteInstallments", loan.Id, null); mockInstalmentManager.Expect("AddInstallments", loan.InstallmentList, loan.Id, null); mockLoanManager.Expect("UpdateLoan", loan, null); LoanServices loanServices = new LoanServices((InstallmentManager)mockInstalmentManager.MockInstance, null, (LoanManager)mockLoanManager.MockInstance); loanServices.SaveLoan(ref loan, 2, ref person); }
public void SaveLoan_AddLoan_ProjectIsEmpty() { Loan loan = new Loan { Amount = 11, InterestRate = 1, NbOfInstallments = 3, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), GracePeriod = 2 }; LoanServices loanServices = new LoanServices(new User()); IClient person = new Person(); loanServices.SaveLoan(ref loan, 0, ref person); }
public void SaveLoan_AddLoan_Person() { DynamicMock mockClientManager = new DynamicMock(typeof(ClientManager)); DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); Loan loan = new Loan { Amount = 11, Code = "Test", InterestRate = 1, NbOfInstallments = 2, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, Events = new EventStock(), NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), LoanEntryFeesList = new List<LoanEntryFee>(), GracePeriod = 2, StartDate = new DateTime(2009,1,1), FundingLine = new FundingLine { Currency = new Currency { Code = "Code", Name = "Name" } }, LoanOfficer = new User(), Product = new LoanProduct { Currency = new Currency { Code = "Code", Name = "Name" } }, InstallmentList = new List<Installment>{_installment1,_installment2} }; IClient person = new Person { Active = false, LoanCycle = 1, Branch = new Branch() { Code = "test" } }; mockLoanManager.ExpectAndReturn("Add", 1, loan, 2, null); mockClientManager.Expect("UpdateClientStatus", person, null); mockClientManager.Expect("UpdateClientLoanCycle", person, null); LoanServices loanServices = new LoanServices(null, (ClientManager)mockClientManager.MockInstance, (LoanManager)mockLoanManager.MockInstance); loanServices.SaveLoan(ref loan, 2, ref person); Assert.AreEqual(1, loan.Id); Assert.AreEqual(new DateTime(2009,2,1),loan.CloseDate); Assert.AreEqual(OContractStatus.Pending, loan.ContractStatus); Assert.AreEqual(1, person.LoanCycle); }
public void SaveLoan_AddLoan_Person_RaisedException_RollBackObjects() { DynamicMock mockClientManager = new DynamicMock(typeof(ClientManager)); DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager)); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); Loan loan = new Loan { Amount = 11, InterestRate = 1, NbOfInstallments = 2, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), GracePeriod = 2, StartDate = new DateTime(2009, 1, 1), FundingLine = new FundingLine { Currency = new Currency { Code = "Code", Name = "Name" } }, LoanOfficer = new User(), Events = new EventStock(), Product = new LoanProduct { Currency = new Currency { Code = "Code", Name = "Name" } }, InstallmentList = new List<Installment> { _installment1, _installment2 } }; IClient person = new Person { Active = false, LoanCycle = 1 }; mockLoanManager.ExpectAndReturn("Add", 1, loan, 2, null); mockClientManager.Expect("UpdateClientStatus", person, null); mockClientManager.Expect("UpdateClientLoanCycle", person, null); LoanServices loanServices = new LoanServices(null, (ClientManager)mockClientManager.MockInstance, (LoanManager)mockLoanManager.MockInstance); try { loanServices.SaveLoan(ref loan, 2, ref person); //Exception because branchCode is null Assert.Fail(); } catch (Exception) { Assert.AreEqual(0, loan.Id); Assert.AreEqual(DateTime.MinValue, loan.CloseDate); Assert.AreEqual(DateTime.MinValue, loan.CreationDate); Assert.AreEqual(1, person.LoanCycle); } }
public void SaveLoan_AddLoan_FundingLineCurrencyIsNotEqualToProductCurrency() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); Loan loan = new Loan { Amount = 11, InterestRate = 1, NbOfInstallments = 3, InstallmentType = new InstallmentType(), AnticipatedTotalRepaymentPenalties = 2, NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), GracePeriod = 2, StartDate = new DateTime(2009, 1, 1), FundingLine = new FundingLine{Currency = new Currency{Code = "Code",Name = "Name"}}, LoanOfficer = new User(), Product = new LoanProduct { Currency = new Currency { Code = "Code2", Name = "Name2" } } }; LoanServices loanServices = new LoanServices(new User()); IClient person = new Person { Active = false }; loanServices.SaveLoan(ref loan, 1, ref person); }