为什么使用此代码 MSTest 和 TestDriven.NET 的行为不同?
查看此代码:
internal static readonly Dictionary<Type, Func<IModel>> typeToCreator = new Dictionary<Type, Func<IModel>>();
protected static object _lock;
public virtual void Register<T>(Func<IModel> creator)
{
lock (_lock)
{
if (typeToCreator.ContainsKey(typeof(T)))
typeToCreator[typeof(T)] = creator;
else
typeToCreator.Add(typeof(T), creator);
}
}
当我在该测试中运行代码时(testframework 是 MSTest):
[TestMethod]
public void Must_Be_BasePresenterType()
{
var sut = new ListTilbudPresenter(_tilbudView);
Assert.IsInstanceOfType(sut, typeof(BasePresenter));
}
...MSTest 通过了它,而 TestDriven.NET 失败了,因为 _lock 为 null。
为什么 MSTest 没有通过测试???
Check out this code:
internal static readonly Dictionary<Type, Func<IModel>> typeToCreator = new Dictionary<Type, Func<IModel>>();
protected static object _lock;
public virtual void Register<T>(Func<IModel> creator)
{
lock (_lock)
{
if (typeToCreator.ContainsKey(typeof(T)))
typeToCreator[typeof(T)] = creator;
else
typeToCreator.Add(typeof(T), creator);
}
}
When I use run the code in this test (testframework is MSTest):
[TestMethod]
public void Must_Be_BasePresenterType()
{
var sut = new ListTilbudPresenter(_tilbudView);
Assert.IsInstanceOfType(sut, typeof(BasePresenter));
}
...MSTest passes it and TestDriven.NET fails it because _lock is null.
Why does MSTest NOT fail the test???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论