是否有可能写棱镜的应用程序,使它们可以在没有用户界面进行测试? [英] Is it possible to write Prism apps such that they can be tested without the UI?

查看:128
本文介绍了是否有可能写棱镜的应用程序,使它们可以在没有用户界面进行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免责声明:棱镜新手。我读了奋力弥补失去的时间,虽然:)

Disclaimer: Prism Novice. I'm reading up furiously to make up for lost time though :)

语境:我需要写自动化验收测试使用Prism内置了WPF应用程序

Context: I need to write automated acceptance tests for a WPF application built using Prism.

问题:我觉得这是令人费解试图组成后盾的ViewModels和一切,他们需要没有UI

Issues: I find that it is convoluted trying to compose the backing ViewModels and everything that they need without the UI.

我可能是错在这里...棱镜可以让你标记的外壳,命名占位符(地区)。不同的模块(隔离的单位)注册了自己的看法与相应RegionNames。该意见还对视图模型(构造函数注入),它是通过MEF /统一注入的依赖。

I may be wrong here... Prism allows you to mark up the shell with named placeholders (regions). Different modules (isolated units) register their Views with the corresponding RegionNames. The Views also have a dependency on the ViewModel (ctor injection) which is injected via MEF/Unity.

  1. 显示视图
  2. 在触发创建子视图(regionName =>查看注册表)
  3. 在触发创建子视图模式(MEF构造函数注射液)。

撰写应用程序因此委托给棱镜(或更重要的是查看)。这似乎是一个视图优先的方法。这引发了对工程启动无用户界面的应用程序中的扳手;测试与UI是一种痛苦。

Composing the app is thus delegated to Prism (or more importantly the View). This seems like a view-first approach. This throws a spanner in the works for starting up the app without the UI ; testing with the UI is a pain.

我所寻找的是一个presenter第一种方法,它构成了整个对象(视图模型和依赖性)图形没有用户界面。

What I am looking for is a presenter first approach, which composes the entire object (ViewModel and dependencies) graph without the UI.

var viewModel = Someone.ComposeAndGet<ShellViewModel>();

是否有可能与PRISM4通过编写应用程序的不同或者是它不支持?

Is it possible with Prism4 by writing apps differently OR is it not supported ?

[更新:2011年12月]
HTTP://compositewpf.$c$cplex.com/discussions/283065
发表于棱镜论坛获得摆脱一些更多的光线;好像它是不可能的。该建议是使用的UI测试验收测试。棱镜组成的用户界面;从而对景观的重要依赖。

[Update : Dec 2011]
http://compositewpf.codeplex.com/discussions/283065
Posted on the prism forums to get shed some more light; seems like it is not possible. The recommendation is to use UI tests for acceptance tests. Prism composes UIs ; thereby has a crucial dependency on views.

推荐答案

我喜欢的棱镜框架,但是我很少用棱镜的地区,因为我觉得它迫使我成为一个视图优先的方法。

I like the Prism framework, however I rarely use Prism's Regions because I feel it forces me into a View-First approach.

我不喜欢使用视图 - 首先,因为我觉得它消除了一些使用MVVM设计模式,如保持你的层分离,单元测试的优势。如果您的视图是负责创建你的ViewModels,然后测试你的ViewModels您可能需要创建视图创建的ViewModels,或者您需要手动创建的ViewModels。

I dislike using View-First because I feel it eliminates some of the advantages of using the MVVM design pattern, such as keeping your layers separate, and unit testing. If your Views are responsible for creating your ViewModels, then to test your ViewModels you either need to create the Views to create the ViewModels, or you need to manually create your ViewModels.

我也觉得一个理想的MVVM应用程序应该允许您运行任何用户界面,甚至是命令行,并通过使用地区,我限制我的ViewModels到棱镜界面的应用程序。

I also feel that an ideal MVVM application should allow you to run the application with any UI, even command-line, and by using Regions I am limiting my ViewModels to a Prism interface.

我仍然会使用之际棱镜的地区,但通常只为启动页面(如TitleBarRegion,MenuRegion,ContentRegion)

I'll still use Prism's regions on occasion, but usually only for the startup page (e.g. TitleBarRegion, MenuRegion, ContentRegion)

这篇关于是否有可能写棱镜的应用程序,使它们可以在没有用户界面进行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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