comecme (1) [Avatar] Offline
#1
Anyone got the source code working on a default install of Visual Studio 2017?

I have Visual Studio 2017 installed, currently version 15.8.6.
I run into several problems when trying to use the source code for this book.

  • MVC version

  • SQL Express versus LocalDB

  • Test Explorer not able to run unit tests


  • Solutions like CommerceWeb contain MVC projects that won't load because it's an old version of MVC.
    There is some info on the web about migrating to newer versions of MVC, but I did not yet get it to work.

    Did get it to load however, but then I got a message about the project using SQL Express where my machine only has LocalDB.

    In my opinion, the publisher should provide an updated version of the example source code, as long as the book is being sold.

    Another problem I ran into is in the HelloDI solution's unit tests.

    VS2017's Test Explorer does find the unit test in the solution, but when I try to run them, the output window shows:

    [9-10-2018 20:00:20 Informational] Test project HelloDIUnitTest does not reference any .NET NuGet adapter. Test discovery or execution might not work for this project.
    It's recommended to reference NuGet test adapters in each test project in the solution.

    This seems to be related to a breaking change in VS2017 15.8.0, requiring a Test Adapter. But trying to install NuGet-package MSTest.TestAdapter won't work, as it does not support .NET Framework 4.0. It needs at least version 4.5. Update the target version of the Unit Test project fixes that, so now I can install the MSTest.TestAdapter.
    Now, however, the version of Moq that's referenced only supports versions 3.5 and 4.0, so we have to upgrade the Moq NuGet packag (currently version 4.10.0).

    After all that, the project builds just fine, but trying to run all tests from Test Explorer now leads to another message:
    [9-10-2018 20:09:57 Warning] No test is available in C:\Projects\DependencyInjectionInDotNet\HelloDI\HelloDIUnitTest\bin\Debug\Ploeh.Samples.HelloDI.UnitTest.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
    

    Maybe I did not need to install MSTest.TestAdapter but a test adapter for xunit? Does one exist? I don't know.

    I just want to learn about Dependency Injection and use the sample code. I do not want to investigate update an old VS2010 solution.