vendredi 4 janvier 2019

Unit Test with Generics types

I want to test an unit test with Generics , and I am STRUGGLING to find the rigth way.

I have this

[TestCase(typeof(CalendarGeneralCsv), typeof(CalendarGeneralCsvMap), 121)]
public void ReadFromCsvFileWithConfigurationMapTest<T,Tmap>(T t, Tmap tmap, int totalRowsExptected)
{
   //Arrange

   //Act
    var records = csvService.ReadFileCsv<T, Tmap>(_csvToRead, ",") as IEnumerable<object>;

     var result = new List<object>(records);

     //Assert
     result.Should().NotBeNullOrEmpty();
     result.Should().HaveCount(totalRowsExptected);
}

the error is in this line

  var records = csvService.ReadFileCsv<T, Tmap>(_csvToRead, ",") as IEnumerable<object>;

Say that T, and Tmap must be a reference type.

Thanks in advance. Best regards, Jolynice

Aucun commentaire:

Enregistrer un commentaire