Testing our C# code
Now that we have our SQL covered, let's go back to our C# code for a bit. There is not really anything to unit test, as we have little to no business logic. It is all just selecting data and returning it to the frontend. Great for E2E tests; not so great for unit testing. So, just as in Node.js, let's create an Order.cs file and pretend we need it for invoicing later. I have created a new folder in the project root and named it Invoicing. In it, I have placed two files, Order.cs and OrderLine.cs. Both are pretty straightforward.
The OrderLine class is pretty much the same as in JavaScript, except we can work with the decimal data type which does not have rounding errors and so we do not need to round. The methods GetSubTotal ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access