private static void Main() { var payslipGenerator = new EmployeePayslipGenerator(); Console.WriteLine("Payslip program executing\n"); var payslips = payslipGenerator.ProcessPayslips(); Console.WriteLine("Payslip Input:"); Console.WriteLine(payslipGenerator.GetInputFile().Contents); Console.WriteLine("\n----------------------------------------------------------------------------------------------\n"); Console.WriteLine("Payslip Output:"); payslipGenerator.ProcessValidInputs(payslips.validPayslips); Console.WriteLine(); Console.WriteLine("Payslip program completed"); Console.WriteLine(); Console.WriteLine("\n----------------------------------------------------------------------------------------------\n"); payslipGenerator.ProcessInvalidInputs(payslips.invalidPayslips); // Simulate injection of a different implementation of payslip, calculator and processor SecretPayslipCalculator shhhhhCalculator = new SecretPayslipCalculator(); SecretPayslipProcessor shhhhhProcessor = new SecretPayslipProcessor(); SecretPayslipFileStructure shhhhhInput = new SecretPayslipFileStructure(); var underTheTablePayslipGenerator = new EmployeePayslipGenerator(shhhhhInput, shhhhhCalculator, shhhhhProcessor); var shhhhhpayslips = payslipGenerator.ProcessPayslips(); var JSONreturn = underTheTablePayslipGenerator.ProcessValidInputs(shhhhhpayslips.validPayslips); }
public void PayslipProgram_WhenUsingGivenInputs() { const string contents = "David,Rudd,60050,9%,01 March – 31 March\nRyan,Chen,120000,10%,01 March – 31 March"; var csv = new CsvInputFile(contents, new[] { '\n' }, new[] { ',' }); var payslipGenerator = new EmployeePayslipGenerator(csv); var expectedReturnTuple = ( new List <BaseValidPayslip> { new PayslipEntity("David", "Rudd", new PayPeriod("01 March – 31 March"), 5004, 922, 4082, 450), new PayslipEntity("Ryan", "Chen", new PayPeriod("01 March – 31 March"), 10000, 2696, 7304, 1000) }, new List <BaseInvalidPayslip>() ); var payslips = payslipGenerator.ProcessPayslips(); CollectionAssert.AreEqual(expectedReturnTuple.Item1, payslips.validPayslips); CollectionAssert.AreEqual(expectedReturnTuple.Item2, payslips.invalidPayslips); }
public void PayslipProgram_WhenUsingErrorProneInputs() { const string contents = "David,Rudd,60050,-9%,01 March – 31 March\n120000,10%,01 March – 31 March"; var csv = new CsvInputFile(contents, new[] { '\n' }, new[] { ',' }); var payslipGenerator = new EmployeePayslipGenerator(csv); var expectedReturnTuple = ( new List <BaseValidPayslip>(), new List <BaseInvalidPayslip> { new InvalidEmployeeInformationEntity("David,Rudd,60050,-9%,01 March – 31 March", "AnnualSalary must be between 0 - 100%!"), new InvalidEmployeeInformationEntity("120000,10%,01 March – 31 March", "Missing fields!") } ); var payslips = payslipGenerator.ProcessPayslips(); CollectionAssert.AreEqual(expectedReturnTuple.Item1, payslips.validPayslips); CollectionAssert.AreEqual(expectedReturnTuple.Item2, payslips.invalidPayslips); }