The following constructor parameters did not have matching fixture data

This article shows how to get xunit working with .Net Core ASP.Net really well. It actually replaces the startup so that your controllers run in the same process, and you can test them as if they were local.

https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests

It allows your standard .Net Dependency Injection to work as it normally does. Moreover it has the amazing benefit of not running as a server, and it fakes the whole startup process so that it runs in one single process and you can debug all the way through. This is also the way you should do it because Microsoft says so.

There's more help to be gleaned from the forum at the bottom of the article.


For the testing framework, you need the mocking library to inject a mock object through DI in your testing classes. You can use Nmock, Moq or any other mocking library to setup the constructor injection.

https://www.c-sharpcorner.com/uploadfile/john_charles/mocking-in-net-with-moq/

http://nmock.sourceforge.net/quickstart.html


Just new up CustomerController in the constructor, if you don't want to use any mocking framework.


What you are missing is the IClassFixture interface for the test class. This will fix the problem...

public class UnitTest1 : IClassFixture<CustomerController>