I'm trying to work out how to do that, starting with a method that fetches all of the data from the database and saves it to a list (it's async, seems like it's causing a lot of trouble). It's a really tough nut to crack, I'm reading stackoverflow, tried the documentation for NSubstitute but there isn't much there tbh. I'm trying to notice a pattern in the code fragments provided but I don't know. I wasn't able to do much on my own because of conflicting information.
I'm pretty sure I got the next part wrong but:
The documentation says that for the substitutions I should use an interface, not a class to avoid some weird behaviour. Ok, I can make that to substitue the database context class but the controller constructor doesn't want an interface, only the context class (I'm fully aware this might be a design mistake on my side because I'm the one that made all that lol). It seems that the substitutes need to have their behaviour specified manually but I don't understand that either.
One person has told me that I don't really need to test crud if it's not complicated but apart from the API I also have a web app and that definitely needs testing (also implementing error handling) but I wanted to learn on something less intimidating first.