1

I'm going through a Lynda training course on Azure APIs. The instructor is doing some unit tests using MSTest. I've followed his code, but am getting the following error:

Test Name: CustomerGetAllTest Test FullName: H_Plus_Sports.Tests.CustomerIntegrationTests.CustomerGetAllTest Test Source: I:\ScratchSrc\H_Plus_Sports\H_Plus_Sports.Tests\CustomerIntegrationTests.cs : line 21 Test Outcome: Failed Test Duration: 0:00:00.2810103

Result StackTrace: at H_Plus_Sports.Startup.ConfigureServices(IServiceCollection services) --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection) at H_Plus_Sports.Tests.CustomerIntegrationTests..ctor() in I:\ScratchSrc\H_Plus_Sports\H_Plus_Sports.Tests\CustomerIntegrationTests.cs:line 16 Result Message: Unable to create instance of class H_Plus_Sports.Tests.CustomerIntegrationTests. Error: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified..

I don't understand why I'm getting the complaint about MSTest not being able to find the Microsoft.AspNetCode.Mvc file.

halfer
  • 19,824
  • 17
  • 99
  • 186
Rod
  • 4,107
  • 12
  • 57
  • 81
  • 1
    Maybe the user the test runs under lacks the rights to access the folder? Maybe you did not copy that file to the output directory/test directoy? – Christopher Oct 18 '18 at 16:30
  • 1
    Rui, thank you very much for giving me that link. That did resolve the problem. I tried searching using the keywords, but I must not have used the right ones, because I didn't find that link. Thanks again, this solves my problem. – Rod Oct 18 '18 at 17:11
  • 1
    No problem, I'm glad I could help :) – Rui Jarimba Oct 18 '18 at 17:16

1 Answers1

0

Few possible problems: Try running program as administrator. Make sure the path is correct or the file is there.

Issue with relative/absolute path, sometimes the program will take a relative path and think that the path you provided is within the solution directory.

Katada
  • 81
  • 3
  • Katada and Christopher, thank you for suggesting the possibility of not having the necessary permissions. That might be the problem, but I'm not sure. And unfortunately, I can't test it. I'm working a laptop with limited disk space, so I put the projects onto a network share. I just tried running VS 2017 as Administrator. I will not open any project on the network share; VS doesn't see the network share. And I haven't enough room on my laptop's HD for projects. – Rod Oct 18 '18 at 16:56