public void ConvertToCsv_Test(List <Person> People, List <string> csvLines) { // Arrange // Act List <string> ConvertedCsvLines = DummyCsv.ConvertToCsv(People); // Assert Assert.Equal(csvLines, ConvertedCsvLines); // Xunit is smart enough to recongise collections so we don't need to do anything special }
[MemberData(nameof(Data))] // Need to user MemberData rather than Inline Data to pass lists public void LoadPeople_FileExists(List <string> csvLines, string filename) { // Arrange // need to create the file - we can delete it and tidy up afterwards File.WriteAllLines(filename, csvLines); // Act List <Person> loadedPeople = DummyCsv.LoadPeople(filename); // Assert Assert.Equal(csvLines.Count, loadedPeople.Count); // check that we have loaded the same amount of people we have added // Cleanup File.Delete(filename); }
public void LoadPeople_NoFile() { string testString = "THISFILEDOESNOTEXIST.TXT"; Assert.Throws <System.IO.FileNotFoundException>(() => DummyCsv.LoadPeople(testString)); }