Easy to Start Unit Testing

You have activated Typemock Isolator.
Following is a quick recipe for getting started

Step 1. Create a Unit Test Project

  On the File menu, choose New and then choose Project (Keyboard Ctrl + Shift + N)
1. Create a new project (Ctrl+Shift+N)
Unit Test Project  
2. Choose Unit Test Project from the list of project templates.
This will create the unit test project, class and method
  Add Typemock.ArrangeActAssert.dll and TypeMock.dll
3. Add Typemock References:
On Project right click Add References.

"Typemock Isolator C# API" and
"Typemock Isolator Core DLL"

Click OK.

You have completed setting up the unit test project, now you are ready to start writing your first test

Step 2. Write Isolated Unit Tests

using TypeMock.ArrangeActAssert
                        namespace Typemock.Examples.CSharp.Basics
                        [TestClass, Isolated]
                        public class BasicUnitTesting
1. In the unit test class add the following
using TypeMock.ArrangeActAssert;
2. Add the Isolated attribute to the test class:
[TestClass, Isolated]
public class BasicUnitTesting
                        public void FakingDateTime()
                        Isolate.WhenCalled(() => DateTime.Now).WillReturn(new DateTime(2016, 2, 29));
                        int result = MyCode.DoSomethingSpecialOnALeapYear();
                        Assert.AreEqual(100, result);
3. There are three parts to each test:

a. Arrange - setup behavior of your fakes.
b. Act - call your code.
c. Assert - check that your code works.

See the example on the right and more examples below.


Step 3. Run the Test

  Typemock SmartRunner will run the tests for you
Typemock Isolator is setup to Run Affected Tests After Build. All you need to do it check that the shields are green.
When the shield is red, Typemock Isolator will take you to the broken test.

This way you get instant feedback and don't have to remember what tests to run.

Step 4. More Examples

Now you can begin to discover the powerful mocking features.
Click here to see some cool stuff including:
  • Unit Testing Legacy Code
  • Faking Sealed Types
  • Recursive Faking
  • Setting behavior on a chain
  • Faking Live Objects
  • Faking Constructors
  • Verifying Calls
  • Many more examples


The Typemock Team