At Typemock, we’re constantly looking for ways to make unit testing easier, smarter, and more developer-friendly—especially for teams working in complex enterprise environments.
Today, we’re excited to announce two new open-source GitHub projects packed with real-world Typemock unit testing examples for both .NET and C++:
These repositories provide clean, readable sample tests to help you master mocking, isolation, and robust test design—without the headaches.
Why Did We Launch These?
We’ve seen time and time again that developers want more than documentation— they want working code.
Whether you’re a .NET developer writing MSTest or xUnit tests with Isolator, or a C++ engineer exploring how to isolate static and global functions using Isolator++, these repositories are for you.
What’s Inside the .NET Examples Repo
- How to isolate dependencies without modifying source code
- Mocking static and private methods
- Faking return values and verifying interactions
- Patterns for writing testable services in legacy codebases
Sample Code:
1 2 3 4 5 6 7 8 9 10 11 |
[Test] public void Should_ReturnPremiumPrice_WhenUserIsPremium() { var userService = Isolate.Fake.Instance<IUserService>(); Isolate.WhenCalled(() => userService.IsPremium("john")).WillReturn(true); var calc = new PriceCalculator(userService); var result = calc.GetPrice("john", 100); Assert.AreEqual(90, result); } |
What’s Inside the C++ Examples Repo
- Mocking global and static methods using Isolator++
- Using WillReturn, WillDoInstead, and verifying calls
- Examples using the new v5 API
- Linux and Windows support (GCC 5.4+ / C++14)
Sample Code:
1 2 3 4 5 6 7 |
TEST(MyTest, ShouldReturnMockedValueFromStatic) { Isolate a; a.CallTo(SomeClass::GetValue).WillReturn(99); int result = MyComponent().Compute(); ASSERT_EQ(result, 99); } |
For Beginners and Pros Alike
- Clear setup instructions
- Comments explaining each step
- Best practices for mocking and test structure
- How to use Typemock in CI pipelines
Get Involved
Want to contribute your own examples or improvements?
Fork, star, or submit a PR on:
Start Writing Smarter Tests
Unit testing is more than a checkbox. It’s how we build clean code, deliver agile value, and stay confident during change.
Try the examples today—and level up your testing:
👉 Download Typemock Isolator for .NET
👉 Download Typemock Isolator++ for C++