Single test file analysis routines?

I'm struggling a bit with how I can unit test parse a file ... Let's say I have a file with 25 columns that can be anywhere from 20-1000 records ... How do I write unit test against this? The function takes the file as a string as a parameter and returns a DataTable with the contents of the file ...

The best I can think of is to parse 4-entry files and check only the upper left and lower right corners ... for example. the first few fields in the 2 upper records and the last few fields of the two lower records ... I could not imagine to tediously give type approval instructions for each individual field in the file. And the execution of just one record and each field seems equally weak, because it does not take into account the scripts of several record files or unexpected data.

At that time, it seemed "good enough" ... however, now I am working on a new project, which is essentially a parsing of different PDF files coming from 10 different sources, each of which has 4-6 different formats for their files, so about 40-60 selection procedures. Ultimately, we can fully automate 25 additional sources in the future. We take a PDF file and convert it to excel using a third-party tool. Then we sit and analyze the output patterns and write the code that calls the tool API, takes the excel file and analyzes it - removing garbage, sorting data in different places, cleaning, etc.

How can I really unit test something like this?

+3
source share
2

, , . , . DataTables DataTables , , . DataTable XML unit test PDF .

PDF DataTable "" DataTable.

. , .

"". , .NET. . 40 " " VBA.... input - Excel - Excel... ? , ????

, Excel , , ; , Assert.AreExcelWorksheetsEqual(). , .

+3

, . 10K . .

, , . / . , - SQL.

+2

Source: https://habr.com/ru/post/1723427/


All Articles