Visual Studio - Git, Testing, and NuGet Packages

 Visual Studio: 

  Git:

      On VS 2022, make sure that Visual Studio Installer has "Code Tools" > "Git for Windows" checked so that it is fully installed.  Even partially installed you can clone down to the box, it correctly shows changes, and even allows committing changes. However, it has problems pushing.  VS says success when pushing but fails to push anything and the changes are remain visible as committed but not pushed and thus cleared out.

      Also make sure you are pointing to correct code branch at the bottom VS task bar.


  Testing - Code Coverage:

    In Test Explorer => click on top level of tests => click "Analyze Code Coverage".

    Click on coverage line to drill down. Keep drilling until know the biggest "Not Covered" and add tests for it and repeat.

  Testing - Exception Testing:

   Say how to mock when call is hit. If NSubstitute then:

   _service.UpdateAllStoreKitchenOnline(Arg.Any<bool>(), Arg.Any<int>(), Arg.Any<string>(), Arg.Any<int>(), Arg.Any<string>()).ThrowsAsync(new Exception());   

   Testing - Unit Testing:

        [TestInitialize]

        public void TestInitialize() _concreteService = MakeService(); }

  NuGet Packages:

    Tools > Options > NuGet Package Manager > Package Sources:

      1) Add the company's global artifactory to the package sources for NuGet packages so solutions will compile.

      2) Add the required NuGet packages that are company-specific found in the Nuget repository that you need.

   Make sure that "Package Source" in NE of Nuget Package Manager screen is set to "All" so that you can see the ones from your custom/company-specific artifactory ones.



    Click project and "Remove Unused Packages" on each

      Do this on each project to minimize packages to have minimal trouble upgrading in future. However, never get rid of MsTest.TestAdapter if it appears on the list because it never has a direct reference.  If you remove MsTest.TestAdapterthen you cannot run tests.


    Click solution or project > Manage NuGet Packages:

      1) Make sure all the project have the minimal "Updates" (under the "Updates" tab) to have easier time with Mend or other version checking.

      2) For QT NuGet projects that complain about downgraded NuGet packages that is a "Transitive Package" under "Installed", add that specific package to the project with latest version. Then VS will use the latest version of the package even though the old QT package has old version it wants. (So specific NuGet package in a project has priority over the package's internal NuGets.)

      3) Install NuGet packages in the projects rather than the solution (unless used in all projects) for same reason.

Comments

Popular posts from this blog

Upgrading to .NET8 from desktop versions 4.8.X

GHL Chat Bots for Webpage

GHL > Set website so shorter URL address