Jer*_*olt 54 .net c# testing moq mocking
我在哪里可以找到MOQ的综合文档?我只是从嘲笑开始,我很难理解它.我已经阅读了http://code.google.com/p/moq/wiki/QuickStart上的所有链接,但似乎无法找到教程或温和的介绍.
我还简要介绍了Rhino Mocks,但发现它非常令人困惑.
是的 - 我读过Stephen Walthers的文章 - 非常有帮助.我也通过了链接.我似乎无法在http://www.bestechvideos.com/2008/06/08/dimecasts-net-introduction-to-mocking-with-moq 观看视频[断链]
具体来说,我试图确定是否从模拟类中引发了一个事件.我无法获得QuickStarts页面上的事件编译示例.在google组中,Daniel解释说CreateEventHandler只能处理类型的事件EventHandler<TEventArgs>
,但即使这样我也无法获得编译代码.
更具体地说,我有一个实现的类INotifyChanged
.
public class Entity : INotifyChanged
{
public event PropertyChangingEventHandler PropertyChanging;
public int Id
{
get {return _id;}
set {
_id = value;
OnPropertyChanged("Id");
}
}
protected void OnPropertyChanged(string property)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
etc .....
}
Run Code Online (Sandbox Code Playgroud)
如何模拟该类以测试PropertyChanged
事件是否被触发?我不能重写事件,public event EventHandler<PropertyChangedEventArgs>
因为我得到这个错误:
错误1'CoreServices.Notifier'未实现接口成员System.ComponentModel.INotifyPropertyChanged.PropertyChanged'.'CoreServices.Notifier.PropertyChanged'无法实现'System.ComponentModel.INotifyPropertyChanged.PropertyChanged',因为它没有匹配的返回类型'System.ComponentModel.PropertyChangedEventHandler'.
Dyl*_*tie 31
Moq的最新文档现在可以在github wiki页面上找到:
https://github.com/Moq/moq4/wiki/Quickstart
以前他们使用的是Google Code.除了wiki和其他在线资源之外,还有Moq主页上链接的Moq二进制下载中包含的Windows .CHM帮助文件格式的完整文档.
归档时间: |
|
查看次数: |
37829 次 |
最近记录: |