如何嘲笑一切? [英] How to mock everything?

查看:124
本文介绍了如何嘲笑一切?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解如何模拟接口或虚拟方法调用.但是像TypeMock这样的框架可以模拟框架中的所有内容.哪些.NET机制用于提供此类功能?

I understand how to mock interfaces or virtual method calls. But frameworks like TypeMock can mock everything in the framework. Which .NET mechanisms are used to provide such functions?

推荐答案

Typemock隔离器使用CLR 分析器API 来拦截.NET调用并在运行时进行更改:

Typemock Isolator for example uses the CLR profiler API to intercept .NET calls and change them during runtime:

报价:

Typemock隔离器使用 面向方面的程序设计 创建一个模拟方面. 在内部,它使用.NET Framework 探查器API来监视 应用程序的执行.当一种方法 由CLR Typemock加载 隔离器检索IL并替换 它与检测的IL代码一起使用.打字模拟 隔离器不会更改您的原件 IL代码,它只是插入新代码 调用Typemock隔离器 框架并返回模拟值.

Typemock Isolator uses an aspect-oriented programming design that creates a mock aspect. Internally, it uses the .NET Framework profiler API to monitor an application's execution. When a method is loaded by the CLR, Typemock Isolator retrieves the IL and replaces it with instrumented IL code. Typemock Isolator does not change your original IL code, it simply inserts new code that calls the Typemock Isolator framework and returns mocked values.

这篇关于如何嘲笑一切?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆