public void TransformerFactory_FetchTransformer_Returns_CSVTransformer_Instance_On_CSV_File_Upload() { //Arrange _fileExtensionType = FileExtensionType.CSV; //Act var result = _target.FetchTransformer(_fileExtensionType); //Assert Assert.IsInstanceOfType(result, typeof(BaseTransformer)); Assert.IsInstanceOfType(result, typeof(CSVTransformer)); }
public List <EmployeeMonthlyPaySlip> GetEmployeesPaySlip(StreamReader fileStream, FileExtensionType fileExtensionType) { try { _transformer = _transformerfactory.FetchTransformer(fileExtensionType); var employeesMonthlyPaySlip = _transformer.Transform(fileStream); foreach (var employee in employeesMonthlyPaySlip) { var salary = _salaryCalculator.CalculateSalary(employee.AnnualSalary, employee.SuperRate); employee.Salary = new Salary() { GrossSalary = salary.GrossSalary, IncomeTax = salary.IncomeTax, NetIncome = salary.NetIncome, Super = salary.Super }; } return(employeesMonthlyPaySlip); } catch (Exception) { throw; //log messages } }
public List <EmployeeMonthlyPaySlip> GetEmployeesPaySlip(StreamReader fileStream, FileExtensionType fileExtensionType) { try { //write a transform that will read the filestream and give a list by mapping each row in the stream to EmployeeMonthlyPaySlip object //TransformerFactory _transformerFactory = new TransformerFactory(); _transformer = _transformerfactory.FetchTransformer(fileExtensionType); //now we got a list of all the employee payslip info. var employeesMonthlyPaySlip = _transformer.Transform(fileStream); //SalaryCalculator _salaryCalculator = new SalaryCalculator(); //Next step is to calculate the salary part and append the salary part to the above employee payslip object foreach (var employee in employeesMonthlyPaySlip) { var salary = _salaryCalculator.CalculateSalary(employee.AnnualSalary, employee.SuperRate); employee.Salary = new Salary() { GrossSalary = salary.GrossSalary, IncomeTax = salary.IncomeTax, NetIncome = salary.NetIncome, Super = salary.Super }; } return(employeesMonthlyPaySlip); } catch (Exception) { throw; } }
public List <EnglishPremierLeagueTeam> GetTeamsWithLeastGoalDifference(StreamReader fileStream, FileExtensionType fileExtensionType) { try { _transformer = _transformerfactory.FetchTransformer(fileExtensionType); var englishPremierLeagueTeams = _transformer.Transform(fileStream); return(GetTeamWithLeastGoalDifference(englishPremierLeagueTeams)); } catch (Exception) { throw; } }