MVC preVIEW 5 - 渲染以便字符串对于测试 [英] MVC Preview 5 - Rendering A View To String For Testing

查看:106
本文介绍了MVC preVIEW 5 - 渲染以便字符串对于测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在读布拉德·威尔逊后(<一个href=\"http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html\">http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html)在新的ViewEngine变化MVC preVIEW 5,并认为这将是伟大的,是能够呈现的测试,以便字符串使用。我得到的IM pression从文章,它可能是可能的做到这一点,但无法弄清楚如何。

I was reading a post by Brad Wilson (http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html) on the new ViewEngine changes to MVC Preview 5 and thought that it would be great to be able to render a view to string for use in tests. I get the impression from the article that it may be possible to achieve this but cannot figure out how.

我相信这将使我们有我们的一些华廷测试(这是缓慢和不可靠的),因为它将使我们能够检查查看已通过简单地检查字符串预期值/文本正确渲染。做掉

I believe this would enable us to do away with some of our WatIn tests (which are slow and unreliable) as it would allow us to check that the View has rendered correctly by simply checking the string for expected values/text.

有没有人来实现这样的事情?

Has anyone implemented something like this?

推荐答案

这是棘手。你所要做的就是设置Response.Filter属性设置为您实现自定义流类的东西。该MVC的Contrib项目居然有这样的例子。我周围戳在那里。

It's tricky. What you have to do is set the Response.Filter property to a custom stream class that you implement. The MVC Contrib project actually has examples of doing this. I'd poke around in there.

这篇关于MVC preVIEW 5 - 渲染以便字符串对于测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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