public void SetUp() { exoticInstallment = new ExoticInstallment(); exoticInstallment.Number = 1; exoticInstallment.PrincipalCoeff = 0.2; exoticInstallment.InterestCoeff = 0.4; }
public void Remove(ExoticInstallment pExoticInstallment) { _installmentList.Remove(pExoticInstallment); for(int i = 1; i <= _installmentList.Count; i++) { ExoticInstallment installment = (ExoticInstallment) _installmentList[i - 1]; installment.Number = i; } }
public void CheckSumOfInterestAndPrincipal_InterestCoefEgal100_PrincipalCoeffEgal10() { ExoticInstallment exoticInstallment1 = new ExoticInstallment(); exoticInstallment1.InterestCoeff = 70; exoticInstallment1.PrincipalCoeff = 0; ExoticInstallment exoticInstallment2 = new ExoticInstallment(); exoticInstallment2.InterestCoeff = 30; exoticInstallment2.PrincipalCoeff = 10; ExoticInstallmentsTable product = new ExoticInstallmentsTable(); product.Add(exoticInstallment1); product.Add(exoticInstallment2); Assert.IsFalse(product.CheckIfSumIsOk(OLoanTypes.Flat)); }
//fait public ExoticInstallmentsTable AddExoticInstallmentInExoticProduct(ExoticInstallmentsTable product,ExoticInstallment exoticInstallment, int installmentCount, bool declining) { if (!declining) { if(exoticInstallment.PrincipalCoeff == 0 && !exoticInstallment.InterestCoeff.HasValue) throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.ExoticInstallmentIsNull); } exoticInstallment.Number = installmentCount; product.Add(exoticInstallment); return product; }
public void TestFindAllExoticProducts() { ExoticInstallment exo1 = new ExoticInstallment(); ExoticInstallment exo2 = new ExoticInstallment(); ExoticInstallmentsTable services = new ExoticInstallmentsTable(); services.Add(exo1); services.Add(exo2); ExoticInstallmentsTable trade = new ExoticInstallmentsTable(); trade.Add(exo1); trade.Add(exo2); List<ExoticInstallmentsTable> list = new List<ExoticInstallmentsTable>(); list.Add(services); list.Add(trade); mockPackageManagement.SetReturnValue("SelectAllInstallmentsTables", list); ProductServices productServices = SetMockManager(mockPackageManagement); Assert.AreEqual(2,productServices.FindAllExoticProducts().Count); }
public void PackageExoticProductCorrectlySetAndRetrieved() { ExoticInstallmentsTable exoticProduct = new ExoticInstallmentsTable(); ExoticInstallment e1 = new ExoticInstallment(); e1.Number = 1; e1.PrincipalCoeff = 0.23; e1.InterestCoeff = 0.15; exoticProduct.Add(e1); package.ExoticProduct = exoticProduct; Assert.IsTrue(package.ExoticProduct.Equals(exoticProduct)); }
public void TestAddExoticInstallmentInExoticProductWhenInstallmentIsNull() { ExoticInstallmentsTable product = new ExoticInstallmentsTable(); ExoticInstallment exoticInstallment = new ExoticInstallment(); exoticInstallment.InterestCoeff = null; exoticInstallment.PrincipalCoeff = 0; LoanProductManager productManager = new LoanProductManager(DataUtil.TESTDB); ProductServices productServices = new ProductServices(productManager); productServices.AddExoticInstallmentInExoticProduct(product, exoticInstallment, 1, false); }
public void TestAddExoticProductWhenExoticProductCorrectlySet() { ExoticInstallment exo = new ExoticInstallment(); exo.InterestCoeff = 1; exo.PrincipalCoeff = 1; ExoticInstallmentsTable services = new ExoticInstallmentsTable(); services.Add(exo); services.Name = "services"; mockPackageManagement.ExpectAndReturn("AddExoticInstallmentsTable", 1, services); ProductServices productServices = SetMockManager(mockPackageManagement); Assert.AreEqual(1,productServices.AddExoticProduct(services, OLoanTypes.Flat)); }
private void buttonAddExoticInstallment_Click(object sender, EventArgs e) { textBoxExoticInstallmentInterest.Clear(); textBoxExoticInstallmentPrincipal.Clear(); _exoticInstallment = new ExoticInstallment(); if (_product.IsDeclining) { textBoxExoticInstallmentInterest.Enabled = false; _exoticInstallment.InterestCoeff = null; } else { textBoxExoticInstallmentInterest.Enabled = true; textBoxExoticInstallmentInterest.Text = "0"; } textBoxExoticInstallmentPrincipal.Text = "0"; panelExoticInstallment.Visible = true; buttonRemoveExoticInstallment.Enabled = true; buttonSaveExoticProduct.Enabled = true; buttonDecreaseExoticInstallment.Enabled = false; _exoticProduct.Add(_exoticInstallment); _InitializeListViewExoticInstallments(_exoticProduct); panelExoticProductNavigationButtons.Enabled = _exoticProduct.GetNumberOfInstallments > 1; buttonDecreaseExoticInstallment.Enabled = false; listViewExoticInstallments.Items[_exoticProduct.GetNumberOfInstallments - 1].EnsureVisible(); listViewExoticInstallments.Items[_exoticProduct.GetNumberOfInstallments - 1].Selected = true; listViewExoticInstallments.Focus(); }
public void TestAddExoticInstallmentInExoticProductWhenInstallmentIsNotNull() { ExoticInstallmentsTable product = new ExoticInstallmentsTable(); ExoticInstallment exoticInstallment = new ExoticInstallment(); exoticInstallment.InterestCoeff = 0; exoticInstallment.PrincipalCoeff = 0; int number = product.GetNumberOfInstallments; ProductServices productServices = new ProductServices(new User {Id = 1}); Assert.AreEqual(number + 1, productServices.AddExoticInstallmentInExoticProduct(product, exoticInstallment, 1, false).GetNumberOfInstallments); }
/// <summary> /// Add an exotic installment in database /// </summary> /// <param name="exoticInstallment"></param> /// <param name="product"></param> public void AddExoticInstallment(ExoticInstallment exoticInstallment, ExoticInstallmentsTable product) { const string q = @"INSERT INTO ExoticInstallments (number,principal_coeff,interest_coeff,exotic_id) VALUES (@number,@principalCoeff,@interestCoeff,@exoticId)"; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) { c.AddParam("@number", exoticInstallment.Number); c.AddParam("@principalCoeff", exoticInstallment.PrincipalCoeff); c.AddParam("@interestCoeff", exoticInstallment.InterestCoeff); c.AddParam("@exoticId", product.Id); c.ExecuteNonQuery(); } }
private void listViewExoticInstallments_Click(object sender, EventArgs e) { int i = listViewExoticInstallments.SelectedIndices[0]; _exoticInstallment = (ExoticInstallment)listViewExoticInstallments.SelectedItems[0].Tag; textBoxExoticInstallmentPrincipal.Text = (_exoticInstallment.PrincipalCoeff * 100).ToString(); if (_product.IsDeclining) { textBoxExoticInstallmentInterest.Clear(); textBoxExoticInstallmentInterest.Enabled = false; } else { textBoxExoticInstallmentInterest.Enabled = true; textBoxExoticInstallmentInterest.Text = (_exoticInstallment.InterestCoeff * 100).ToString(); } panelExoticInstallment.Visible = true; if (!_useExistingExoticProduct) { panelExoticProductNavigationButtons.Enabled = _exoticProduct.GetNumberOfInstallments > 1; buttonIncreaseExoticInstallment.Enabled = _exoticInstallment.Number != 1; buttonDecreaseExoticInstallment.Enabled = _exoticInstallment.Number != _exoticProduct.GetNumberOfInstallments; } listViewExoticInstallments.Items[i].EnsureVisible(); listViewExoticInstallments.Items[i].Selected = true; listViewExoticInstallments.Focus(); }
public void TestSumForDecliningInterestRateType() { var i1 = new ExoticInstallment() {PrincipalCoeff = 0.7, InterestCoeff = 0}; var i2 = new ExoticInstallment() {PrincipalCoeff = 0.3, InterestCoeff = 0}; var exotic = new ExoticInstallmentsTable(); exotic.Add(i1); exotic.Add(i2); Assert.IsTrue(exotic.CheckIfSumIsOk(OLoanTypes.DecliningFixedPrincipal)); }
public void Add(ExoticInstallment pExoticInstallment) { pExoticInstallment.Number = _installmentList.Count + 1; _installmentList.Add(pExoticInstallment); }
public void TestIsExoticProductForFlatRatePackageWhenItIsNot() { exoticProduct = new ExoticInstallmentsTable(); e1 = new ExoticInstallment(); e1.Number = 1; e1.PrincipalCoeff = 0.4; e1.InterestCoeff = null; e2 = new ExoticInstallment(); e2.Number = 2; e2.PrincipalCoeff = 0.3; e2.InterestCoeff = null; exoticProduct.Add(e1); exoticProduct.Add(e2); Assert.IsFalse(exoticProduct.IsExoticProductForFlatRatePackage); }
public void TestGetSumOfPrincipalCoeffWhenSumIsNull() { ExoticInstallment exoticInstallment1 = new ExoticInstallment(); ExoticInstallment exoticInstallment2 = new ExoticInstallment(); ExoticInstallmentsTable product = new ExoticInstallmentsTable(); product.Add(exoticInstallment1); product.Add(exoticInstallment2); Assert.AreEqual(0,product.SumOfPrincipalCoeff); }
public void TestGetSumOfPrincipalCoeff() { ExoticInstallment exoticInstallment1 = new ExoticInstallment(); exoticInstallment1.PrincipalCoeff = 123; ExoticInstallment exoticInstallment2 = new ExoticInstallment(); exoticInstallment2.PrincipalCoeff = 100; ExoticInstallmentsTable product = new ExoticInstallmentsTable(); product.Add(exoticInstallment1); product.Add(exoticInstallment2); Assert.AreEqual(223,product.SumOfPrincipalCoeff); }
public void SetUp() { exoticProduct = new ExoticInstallmentsTable(); exoticProduct.Id = 1; exoticProduct.Name = "proportional interest rate with 6 installments"; e1 = new ExoticInstallment(); e1.Number = 1; e1.PrincipalCoeff = 0.4; e1.InterestCoeff = 0.2; e2 = new ExoticInstallment(); e2.Number = 2; e2.PrincipalCoeff = 0.3; e2.InterestCoeff = 0.15; exoticProduct.Add(e1); exoticProduct.Add(e2); }
public void Move(ExoticInstallment pExoticInstallment, int pNewPosition) { _installmentList.Remove(pExoticInstallment); _installmentList.Insert(pNewPosition - 1, pExoticInstallment); for (int i = 1; i <= _installmentList.Count; i++) { ExoticInstallment installment = (ExoticInstallment)_installmentList[i - 1]; installment.Number = i; } }