silverlight 的单元测试在哪里?
我正在尝试使用 silverlight 开始单元测试,一些在线示例使用以下语句,
EnqueueCallback
EnqueueConditional
EnqueueTestComplete
这些示例位于何处?
Im tring to start unit testing with silverlight and some of the samples online use the following statements
EnqueueCallback
EnqueueConditional
EnqueueTestComplete
where do these live?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的找到了我的答案。 如果您的测试继承自 WorkItemTest(或PresentationTest 或 SilverlightTest),您将能够从您的测试中调用:
指示框架您的测试方法已完成,并转到下一个结果。 这可以添加到事件回调、委托等中。调用此函数后,您不应该再做任何工作或测试。
将一个操作加入队列以调用 TestComplete。 这是完成一组工作时调用 TestComplete 最常用的方法,通常是最后一次 Enqueue* 方法调用。
将 Action 入队(委托、简单 lambda 等)。 工作项有效地调用操作,然后继续。 或者,此入队方法还采用一组操作,允许您将许多操作调用按顺序链接在一起。
采用 Func 条件语句/谓词。 每次评估工作项时,都会调用该函数。 当它返回 True 时,工作项已完成并且执行将继续。 每次调用谓词后,测试框架都会展开堆栈,允许其他工作发生,然后再返回尝试条件。
此方法会将一个工作项排入队列,该工作项采用 TimeSpan 对象或表示继续之前至少要延迟的毫秒数的整数。 这不是一个精确的计时器,而是一种确保至少持续最短时间的方法。 它更像是 DoEvents 调用,而不是 Sleep 调用,因为它不会阻塞 UI 线程。
Ok found my answer. If your test inherits from WorkItemTest (or PresentationTest, or SilverlightTest), you’ll be able to call from your tests:
Instructs the framework that your test method is finished, and to move onto the next result. This can be added to event callbacks, delegates, etc. You should not do any more work or your test after calling this.
Enqueues an action to call TestComplete. This is the most-used way of calling TestComplete when a set of work is done, and would typically be the last Enqueue* method call.
Enqueues an Action (delegate, simple lambda, etc.). The work item effectively calls the Action, then moves on. Alternatively, this enqueue method also takes an array of Actions, allowing you to chain many Action calls together in order.
Takes a Func conditional statement / predicate. Each time the work item is evaluated, the function is called. When it returns True, the work item is complete and execution will continue. After each invoke of the predicate, the test framework will unwind the stack, allowing other work to happen, before coming back to try the condition again.
This method will enqueue a work item that takes either a TimeSpan object or an integer representing the number of milliseconds at minimum to delay before continuing. This is not an exact timer, but rather, a way to ensure that at least a minimum amount of time continues. It is more like a DoEvents call than it is like a Sleep call, since it will not block the UI thread.