Typemock Isolator dotnet core support

Since version 9 Typemock Isolator fully supports dotnet core.
A little background on .Net Core (dotnet core) and .Net Framework.

.NET Core is a free open source platform, a development platform designed to work on cross-platform development.
Meaning, Software applications on Windows, Linux, and macOS operating systems.

.NET Framework supports Windows and Web applications only.
Including Windows Forms, WPF, and UWP in order to build Windows applications in .NET Framework, and ASP.NET MVC is used in order to build Web applications in .NET Framework.

Since version 5.0 the dotnet core and .NET framework have combined and now are the same platform.

Typemock has worked hard on giving you the perfect solution to keep unit testing your code without modifying your existing tests.
As from version 9 and up of Typemock Isolator, there is no need for both Typemock.dll and Typemock.ArrangeActAssert.dll like before, but only Typemock.ArrangeActAssert.dll.
This means the older APIs (non-AAA) are now deprecated. And dotnet core project can only use the modern AAA APIs.

Luckily, no modification of your AAA unit tests will be needed as Typemock Isolator supports past .NET Framework versions (since version 3.5) as well as the new .NET Core versions and also .NET 5/6 which is the combination of Microsoft’s .NET Framework and Core best features.

Here is a simple small guide on creating a Test project in dotnet core on Visual Studio, adding Typemock to it, and running test using the powerful Typemock APIs:

Step 1: Create Test Project

  1. Start Visual Studio 2022.
  2. Select Create a new project.
  3. In the language section marked in blue select C#.
  4. In the project type section marked in orange select Test.
  5. MSTest Test Project will appear in the table, choose it and click next.
  6. Choose your project name, project location, and solution name, Or you can keep it as default.
  7. Select your target framework, for this example we will choose .NET 5.0, and click the Create button.

 

Step 2: Add Typemock NuGet Package

  1. Right-click on Dependencies that are marked in purple, then click “manage NuGet Packages” which is marked in orange.
  1. The following window will appear, click on “Browse” and type “Typemock”, this will find the “Typemock Isolator” NuGet package.
  2. Choose Typemock.Isolator like in the following picture and click on the Install button that is marked in orange.
  1. A preview window will appear, click “ok” then the license acceptance window will appear, click on “I Accept” now the NuGet package is installed.
    This will add “Typemock.ArrangeActAssert.dll” to your test project.

Step 3: Write a unit test using Typemock API

  1. Add “using TypeMock.ArrangeActAssert;” in order to use Isolator’s API. (see the marked line in the image below)
  2. The [TestClass] attribute needs to be added to the test class so the runners can recognize it as the test class.
    The [TestMethod] attribute needs to be added to the test methods so the runners can recognize them as a test.
    Those attributes are of the MSTest framework.
  1. In the example below you can see a production class that contains a method that returns 100 only when the current date is the 29 of February,
    In the test, the Isolator API is used to fake the DateTime object so any call for that object will return the date as 29 of February 2016.
    In that case in DoSomethingSpecialOnALeapYear, we will receive the DateTime as 29 of February and return 100, and the test will pass successfully.

Step 4: Run the test

  1. To run the test using Typemock SmartRunner – simply build the code and the test will run automatically, or click on the green shield that appears next to each test and select Run Test (see the image below), This also can be done with the Right Mouse Click or Alt-t,t shortcut.
  1. Another way is via the Typemock Test Navigator:
    a. Click Extensions menu->Typemock->Windows->Test Navigator.

    b. In the Test Navigator, if you want to run a particular test click Pending, right-click the test you want to run, and select Run test (see image below).

    c. To run all the pending tests you can simply right-click on the Pending button and select Run All Pending tests (see image below).
  2. To configure the Typemock runner to run the tests after each build opens the Typemock options, Click Extensions->Typemock->Options, which will lead us to the following window where we can choose which options fit us the most.

Step 5: See coverage metrics

  1. In order to see the Solution Coverage, open the Typemock solution coverage window, Click the Extensions menu->Typemock->Coverage->Solution.
    This will open the solution-wide coverage window that will show how well our project is covered (See image below).
  1. In order to see the Incremental Coverage, we will do the same as previously but choose Incremental Coverage.
    That will open the following window that will show live coverage while changing the code.
    It will only show tests that have been affected since the last edit session

    .

We are excited to deliver these features to you, here at Typemock we are working every day to provide the best unit testing solutions with new features and integrations to the hottest releases on the market.
We listen to each and every customer we have and do our best to help them to achieve the most they can with our Isolator.