Unit Testing Asp.NET Core 2.0 Web API

I am having quite the week writing tests for a Web API. I’m using Moq and Xunit. I’m very simply trying to write unit tests for my controllers. I may be over-thinking this whole process because it seems as though it should be pretty straightforward.

Each of my controllers have constructors injected with UserManager<ApplicationUser>. So when I go to write tests, do I need to make a mock of the specific controller and then make a mock of the services injected into that controller? Does anyone have some good examples? I can’t seem to find a clear solution on StackOverFlow.

Thanks!

submitted by /u/TheHeadofShiz
[link] [comments]

Leave a Reply