Test AI

Typemock Isolator 9.3.3: Embracing .NET 9 and C# 13 with AI Testing Capabilities

We are excited to announce the release of Typemock Isolator 9.3.3, the most advanced version yet of our unit testing tool. This release is designed to support the latest innovations in the .NET ecosystem, including .NET 9 and C# 13. Whether you’re exploring AI integration, adopting cutting-edge C# features, or building robust applications, Typemock Isolator provides everything you need to write reliable and maintainable unit tests.


What’s New in Typemock Isolator 9.3.3

1. Full Support for .NET 9

.NET 9 brings significant improvements in performance, cloud-native development, and AI integration. Typemock Isolator 9.3.3 ensures seamless compatibility with .NET 9, allowing you to test modern applications without missing a beat.

2. C# 13 Features for Enhanced Testability

With features like params collection enhancements, partial properties, and the field keyword, C# 13 simplifies coding. Typemock Isolator fully supports these new capabilities, making it easier to write and test code using modern C# constructs.

3. Simplified AI Testing

The rise of AI-driven applications presents unique testing challenges, particularly when working with dynamic behaviors or external dependencies like AI models and APIs. Typemock Isolator 9.3.3 introduces improved support for mocking AI-related libraries, such as those using Microsoft.Extensions.AI.


Testing AI-Driven Applications with Typemock

To demonstrate the power of Typemock Isolator in testing AI integrations, let’s walk through an example of testing code that generates embeddings using the Microsoft.Extensions.AI library.


The Code Under Test

The following AIService class interacts with an external embedding generator to process input text and generate embeddings:

  • IEmbeddingGenerator: An interface for generating embeddings.
  • OllamaEmbeddingGenerator: A concrete implementation interacting with the AI model.

Unit Testing AI Code with Typemock

Using Typemock Isolator, we can test the checkingAIAsync method by mocking the IEmbeddingGenerator interface, allowing us to simulate its behavior without relying on the actual AI service.


Test 1: Simulating an Exception

This test ensures that the method correctly handles exceptions thrown by the embedding generator.

Key Points:

  • Isolate.Fake.NextInstance: Fakes the next instance of IEmbeddingGenerator.
  • Isolate.WhenCalled: Configures the mocked method to throw an exception.
  • The test ensures the AIService handles the exception as expected.

Test 2: Simulating a Successful Response

This test validates that the service correctly processes a valid response from the embedding generator.

Key Points:

  • Isolate.Fake.AllInstances: Ensures all instances of IEmbeddingGenerator are mocked.
  • Simulates a successful response from the AI service.
  • Verifies that the GenerateAsync method is called with the expected arguments.

Why Use Typemock Isolator for AI Testing?

  1. Mocking Complex Dependencies
    • Typemock handles non-virtual methods, static methods, and third-party libraries seamlessly.
      In this case we faked a future instance of a class that implements our interface
  2. Testing Edge Cases
    • Simulate various scenarios, such as exceptions or unusual inputs, without relying on real AI services.
  3. Minimized Refactoring
    • No need to rewrite code for testability, making Typemock ideal for modern AI-driven and legacy systems alike.
  4. Verification
    • Ensure expected behaviors are invoked, and dependencies interact correctly during execution.

C# 13 Features with Typemock

Typemock Isolator’s support for C# 13 features ensures developers can test modern code constructs with ease:

  • Enhanced params Collections: Test methods using advanced collection handling.
  • Partial Properties: Mock and verify getter and setter behaviors separately.
  • field Keyword: Simulate property backing field behavior without explicit field definitions.

Upgrade to Typemock Isolator 9.3.3 Today

Typemock Isolator 9.3.3 provides the tools you need to confidently test AI-driven applications, modern C# 13 code, and .NET 9 projects. With Typemock, you can build robust and maintainable tests for even the most complex scenarios.

👉 Download Typemock Isolator 9.3.3
👉 Explore Documentation