static void Main(string[] args) { string Directory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); bool InputFileFound = false; string[] Inputs = null; try { Inputs = File.ReadAllLines(GetFilePath(true)); InputFileFound = true; } catch (Exception ex) { Console.WriteLine("Input file - " + ex.Message.ToString()); InputFileFound = false; } if (InputFileFound) { foreach (var input in Inputs) { payslips.Add(PayslipCalculatorEngine.GetPayslip(input)); } if (payslips.Count > 0) { WriteOutputToFile(); Console.WriteLine("Output file is available at " + GetFilePath(false)); } else { Console.WriteLine("No inputs found to generate payslip"); } } Console.ReadLine(); }
public void PayslipEngineTest() { string[] Inputs = new string[] { "David,Rudd,60050,9%,01 March – 31 March", "Ryan,Chen,120000,10%,01 March – 31 March" }; string[] Expected = new string[] { "David Rudd,01 March – 31 March,5004,922,4082,450", "Ryan Chen,01 March – 31 March,10000,2696,7304,1000" }; List <string> Actual = new List <string> { }; foreach (var input in Inputs) { Actual.Add(PayslipCalculatorEngine.GetPayslip(input)); } if (Inputs.Length != Expected.Length) { Assert.Fail("Inputs collection are not same length"); } CollectionAssert.AreEqual(Expected, Actual); }