I'm currently creating a function that when a .csv file is uploaded, each field is then read using TextFieldParser. Each field is also validated and the contents of each row are added to a database, with an error displaying to the user if there is a problem with the file. The code validates how many columns (fieldLength), and then each individual column is then validated.
The function works completely fine without issues except I now need to write some tests for the code. I can create a mock filestream, but it fails the validation. Therefore I need to create a mock .csv file with fields that will pass all validation and pass it through as a filestream into the manager.
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire