Entity infrastructure provider not found in unit test
I'm new to dependency and modulation testing (in C #), but I want to learn how to do it for code and testing. I want me to do this in order to create a test that returns some search results from a function that I used in an ASP.NET program.
After doing a lot of searching on the internet, I created a test function. This is what I have so far, but it doesn't work:
[TestMethod]
public void Search_for_a_movie()
{
//Arrange - create a mock repository
Mock<IMovieRepository> mockMovieRepository = new Mock<IMovieRepository>();
mockMovieRepository.Setup(m => m.SearchResults("Avatar")).Returns(new List<Movie>()
{
new Movie {MovieId = 1, MovieName = "Avatar"},
new Movie {MovieId = 2, MovieName = "The Lion King"}
});
EFMovieRepository efMovieRepository = new EFMovieRepository();
var result = efMovieRepository.SearchResults("Avatar");
// Assert
Assert.IsNotNull(result, "It not empty");
}
In var result = efMovieRepository.SearchResults("Avatar");
I am getting an error:
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
App.config:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
I do not know what happened. Can you help me?
+3
source to share
No one has answered this question yet
Check out similar questions: