public void IncomeTaxService_CalculateTax_Test2() { IncomeTaxService service = new IncomeTaxService(); var result = service.CalculateTax(60050, 2017); Assert.AreEqual(result.Tax.RoundOffValue, 11063); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> validationResult = new List <ValidationResult>(); if (string.IsNullOrWhiteSpace(this.Name)) { validationResult.Add(new ValidationResult("Name is required", new List <string> { "name" })); } if (this.Rate.Equals(null) || this.Rate < 0) { validationResult.Add(new ValidationResult("Rate must be greater than zero", new List <string> { "rate" })); } if (validationResult.Count.Equals(0)) { /* Service Validation */ IncomeTaxService service = (IncomeTaxService)validationContext.GetService(typeof(IncomeTaxService)); if (service.DbContext.Set <IncomeTax>().Count(r => r._IsDeleted.Equals(false) && r.Id != this.Id && r.Name.Equals(this.Name) && r.Rate.Equals(this.Rate)) > 0) /* Name and Rate Unique */ { validationResult.Add(new ValidationResult("Name and Rate already exists", new List <string> { "name" })); validationResult.Add(new ValidationResult("Name and Rate already exists", new List <string> { "rate" })); } } return(validationResult); }
public void IncomeTaxService_CalculateTax_Test1() { IncomeTaxService service = new IncomeTaxService(); var result = service.CalculateTax(60050, 2017); Assert.IsNotNull(result); }
public MainWindow() { InitializeComponent(); employeeSalaryService = new EmployeeSalaryService(); incomeTaxService = new IncomeTaxService(); GetEmployeeDetails(); EmployeesPayslip = new ObservableCollection <PaySlip>(); PaySlipVisible = Visibility.Collapsed; this.DataContext = this; }
public void CalculateTax_ShouldReturn_Correct() { var grossSalary = 3400m; var salaryFreeOfTax = 1000m; var expectedResult = 240m; var incomeService = new IncomeTaxService(); var result = incomeService.CalculateTax(grossSalary, salaryFreeOfTax); Assert.AreEqual(expectedResult, result); }
public void SalaryCalculationService_GetSalaryCalculationTest() { EmployeeSalaryService test = new EmployeeSalaryService(); IncomeTaxService test2 = new IncomeTaxService(); var emp = test.GetEmployeeSalary(); foreach (var item in emp) { var taxincome = test2.CalculateTax(item.AnualSalary, 2017); var payslip = test.GetPaySlip(item, taxincome, new SalarySlipPeriod(1, 3)); } System.Diagnostics.Debug.WriteLine("Test"); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> validationResult = new List <ValidationResult>(); if (string.IsNullOrWhiteSpace(this.Name)) { validationResult.Add(new ValidationResult("Name is required", new List <string> { "name" })); } if (this.Rate.Equals(null) || this.Rate < 0) { validationResult.Add(new ValidationResult("Rate must be greater than zero", new List <string> { "rate" })); } if (validationResult.Count.Equals(0)) { /* Service Validation */ IncomeTaxService service = (IncomeTaxService)validationContext.GetService(typeof(IncomeTaxService)); if (service.DbContext.Set <IncomeTax>().Count(r => r._IsDeleted.Equals(false) && r.Id != this.Id && r.Name.Equals(this.Name) && r.Rate.Equals(this.Rate)) > 0) /* Name and Rate Unique */ { validationResult.Add(new ValidationResult("Name and Rate already exists", new List <string> { "name" })); validationResult.Add(new ValidationResult("Name and Rate already exists", new List <string> { "rate" })); } } if (string.IsNullOrWhiteSpace(COACodeCredit)) { validationResult.Add(new ValidationResult("COA harus diisi", new List <string> { "COACodeCredit" })); } else { if (COACodeCredit.Split(".").Count() != 2) { validationResult.Add(new ValidationResult("Format COA salah", new List <string> { "COACodeCredit" })); } else { var firstCOA = COACodeCredit.Split(".")[0]; var secondCOA = COACodeCredit.Split(".")[1]; if (!int.TryParse(firstCOA, out var intFirstCOA) || firstCOA.Count() != 4) { validationResult.Add(new ValidationResult("Format COA salah", new List <string> { "COACodeCredit" })); } else if (!int.TryParse(secondCOA, out var intSecondCOA) || secondCOA.Count() != 2) { validationResult.Add(new ValidationResult("Format COA salah", new List <string> { "COACodeCredit" })); } } } return(validationResult); }
public void IncomeTaxService_CalculateTax_ArgumentNullException_Test() { IncomeTaxService service = new IncomeTaxService(); var result = service.CalculateTax(null, 2017); }