public void ThenTheDestinationFileShouldContainTheFollowing(Table table) { var file = new SpecFlowFile(DestinationFilename); if (!file.Exists) { Assert.Fail("Destination file '{0}' doesn't exists!".Inject(file.FullName)); } IEnumerable <StudentScores> actual = file.ReadAllLines() .SelectMany(line => line.Split('\r')) .Where(csvLine => !string.IsNullOrWhiteSpace(csvLine)) .Select(csvLine => new { data = csvLine.Trim().Split(',') }) .Select(s => new StudentScores { Surname = s.data [ColumnSurname].Trim(), FirstName = s.data [ColumnFirstName].Trim(), Score = s.data [ColumnScore].Trim() }); table.CompareToSet(actual, true); }
public void GivenTheSourceFileContainsTheFollowing(Table table) { var file = new SpecFlowFile(SourceFilename); file.Delete(); IEnumerable <StudentScores> students = table.CreateSet <StudentScores>(); IEnumerable <string> lines = students.Select(s => s.FirstName + ", " + s.Surname + ", " + s.Score); file.WriteAllLines(lines); Console.WriteLine("Created file '{0}'!".Inject(file.FullName)); }