public Practices ExtractPracticesFromCsvLineFormat(string lineAsCsv) { workingText = lineAsCsv; Practices practice = new Practices(); parseNextValueAsString(); practice.ReferenceId = parseNextValueAsString().Trim(); practice.Name = parseNextValueAsString().Trim(); parseNextValueAsString(); practice.Address = parseNextValueAsString().Trim(); practice.City = parseNextValueAsString().Trim(); practice.County = parseNextValueAsString().Trim(); practice.PostCode = parseNextValueAsString().Trim(); return practice; }
public void ReadPrescriptionFromCsvReturnCorrectData() { string filepath = "PracticeTest.csv"; //201202,A81001,THE DENSHAM SURGERY ,THE HEALTH CENTRE ,LAWSON STREET,STOCKTON ,CLEVELAND,TS18 1HU var practice = new Practices(); using (var sr = new StreamReader(filepath)) { string line = null; //Read and display lines from the file until the end of the file is reached. while ((line = sr.ReadLine()) != null) { practice = lineReader.ExtractPracticesFromCsvLineFormat(line); } } Assert.That(practice.ReferenceId, Is.EqualTo("A81001")); Assert.That(practice.Name, Is.EqualTo("THE DENSHAM SURGERY")); Assert.That(practice.PostCode, Is.EqualTo("TS18 1HU")); }