For my company I'm creating an Azure Functions with .NET Core 3.x to generate the invoices. I have to consider different scenarios and I want to create a test for that.
I thought to create a function where I pass a list of lines for the invoice. In this function I have to check if there is any refund for the user: if so, I have to deduct the amount from the current invoice. If some money to refund are left, I have to create a new refund invoice.
public class InvoiceGeneratorResponse
{
public List<InvoiceGeneratorDetailResponse> Details { get; set; }
public List<InvoiceGeneratorErrorResponse> Errors { get; set; }
public List<InvoiceGeneratorNextInvoiceResponse> NextInvoice { get; set; }
}
InvoiceGeneratorResponse is the result of my class where Details is the invoice list, Errors is the list of incomplete invoices and NextInvoice is the list of refund invoices I have to create.
Now, I want to create a bunch of tests to check every scenario. For that, I have to pass the list of rows to this function and check the result.
I was thinking to read the list of rows from a json
file and convert it in a list to pass into the function. For the result I want to read another file, convert it in a list and compare the list from the file with the result from the function.
Is there already an annotation for reading a file in a test? If yes, with what framework? xUnit
? nUnit
? Is there an easy way to fully compare two lists in a test?