单元测试ASP.NET遗产code [英] Unit testing ASP.NET Legacy code

查看:76
本文介绍了单元测试ASP.NET遗产code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ASP.NET遗留项目名单。在这些项目中的业务逻辑紧密地与网页的约束。所有验证和其他的东西写在负载并单击code后面的事件。我使用Visual Studio 2012。

I have list of ASP.NET legacy projects. In these projects business logic is tightly bound with the Pages. All the authentication and other stuff is written in load and click events in the code behind. I am using Visual Studio 2012.

什么是单元的最佳方式测试这些项目?

What is the best way to unit testing these projects?

推荐答案

在单元测试遗留ASP.NET code,一些最困难的挑战是在嘲讽出的东西,如会议,HTTP上下文和页面对象。为了隔离这些,你最终不得不非常杂乱嘲讽逻辑,这通常涉及到很多的反射和运行时间值的注入。

When unit testing legacy ASP.NET code, some of the hardest challenges are in mocking out stuff like the Session, HTTP Context and the Page Object. To isolate these you end up having very messy mocking logic, usually involving a lot of reflection and run-time injection of values.

TypeMock 是无价在这里,因为它有你需要的diificult隔离到模拟类型,如上面的那些一切,并且也有很多帮手,为嘲讽ASP.NET管道不必依靠Web服务器上。

TypeMock is invaluable here as it has everything you need to isolate diificult to mock types like the ones above, and also has a lot of helpers for mocking the the ASP.NET pipeline without having to rely on a web server.

这篇关于单元测试ASP.NET遗产code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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