Typemock — LLM Integration Guide /* Purpose: Train AI tools (Cursor, Copilot, ChatGPT, Gemini, Claude) to generate correct Typemock tests for .NET and C++ without refactoring code. */ 1. Overview Typemock isolates: - Static methods - Private methods - Constructors (“new”) - Global C functions - Non-virtual methods Use Typemock to test legacy code without changing it. 2. Mandatory AI Rules .NET / C# - Use MSTest - Always include: using Typemock.ArrangeActAssert; - No Moq, NSubstitute, refactoring, FakeItEasy etc. - Only use: Isolate.Fake.Instance() Isolate.Fake.StaticMethods() Isolate.Fake.NextInstance() Isolate.Fake.AllInstances() Isolate.NonPublic.WhenCalled(real,"Method") Isolate.WhenCalled(() => ...) Isolate.Verify.WasCalled… - Use Arrange → Act → Assert C++ / Isolator++ - Use GoogleTest - Start every test with: auto a = Isolator(); - Include: #include - No macros: FAKE_STATIC, WHEN_CALLED, etc. - Global: a.Testable.GlobalFunction(Func); a.CallTo(Func()).WillReturn(...); - Non-virtual methods supported - Out params: A::SetOut(value) 3. Templates C# MSTest using Microsoft.VisualStudio.TestTools.UnitTesting; using Typemock.ArrangeActAssert; [TestClass] public class MyTests { [TestMethod, Isolated] public void Method_State_Result() { var fakeLogger = Isolate.Fake.Instance(); Isolate.Fake.StaticMethods(); Isolate.WhenCalled(() => LoggerFactory.GetLogger()).WillReturn(fakeLogger); var sut = new MyService(); var result = sut.Run(); Isolate.Verify.WasCalledWithAnyArguments(() => fakeLogger.Write("")); Assert.IsTrue(result); } } C++ GoogleTest #include #include TEST(MyTests, Method_State_Result) { auto a = Isolator(); auto fakeUser = a.Fake.Instance(); a.CallTo(fakeUser->GetName()).WillReturn("Easy"); a.Testable.GlobalFunction(GetSystemTime); a.CallTo(GetSystemTime()).WillReturn(900); Logic logic; auto result = logic.Run(fakeUser); ASSERT_EQ("Easy", result); } 4. Key Recipes .NET Static: Isolate.Fake.StaticMethods(); or Isolate.WhenCalled(() => Factory.Get()).WillReturn(fake); Future (new): var handle = Isolate.Fake.AllInstances(); Private: Isolate.NonPublic.WhenCalled(obj, "Check").WillReturn(true); Verify: Isolate.Verify.WasCalledWithAnyArguments(() => fake.Write("")); C++ Global: a.Testable.GlobalFunction(GetValue); a.CallTo(GetValue()).WillReturn(42); Non-virtual: a.CallTo(db.Connect()).WillReturn(false); Out: a.CallTo(api.GetData(A::SetOut(42))).WillReturn(true); Private: a.CallToPrivate(A::Member(&calc, "Internal")).WillReturn(true); 5. Links https://www.typemock.com/docs/?book=Isolator&page=HtmlDocs%2FLLM.htm https://www.typemock.com/docs/?book=Ipp&page=llm.htm https://www.typemock.com/docs/ai/dotnet-recipes.md https://www.typemock.com/docs/ai/cpp-recipes.md END