mvc NUNIT System.NotImplementedException:方法或操作未实现
我的 NUnit 遇到一些问题。我有这个 TestFixture 测试模型
是这样的:
public class Model
{
public int Id {get;set;}
public string Name {get; set;}
public void myAction(MyDatabase db, string r, string i) {
db.DataEmp.Add(new DataEmp{
Id = this.Id,
DateOfAction = DateTime.UtcNow,
R = r,
I = i
});
db.SaveChanges();
}
}
My TestCase in NUnit
[Test]
public void Method_Test_Pass_myAction()
{
newModel.myAction(db,"R","I");
Assert.That(db.DataEmp.FirstOrDefault(de => de.Id == newModel.Id), Is.Null);
}
它给了我一个
System.NotImplementedException:该方法或操作未实现。
所以我不确定出了什么问题,因为我在安装方法中实例化了 newModel 。如果运行应用程序,该方法运行良好。 想法受到赞赏。
谢谢!!
having some problems with my NUnit. I have this TestFixture testing a model
model is like this:
public class Model
{
public int Id {get;set;}
public string Name {get; set;}
public void myAction(MyDatabase db, string r, string i) {
db.DataEmp.Add(new DataEmp{
Id = this.Id,
DateOfAction = DateTime.UtcNow,
R = r,
I = i
});
db.SaveChanges();
}
}
My TestCase in NUnit
[Test]
public void Method_Test_Pass_myAction()
{
newModel.myAction(db,"R","I");
Assert.That(db.DataEmp.FirstOrDefault(de => de.Id == newModel.Id), Is.Null);
}
It's giving me a
System.NotImplementedException : The method or operation is not implemented.
So I'm not sure what's wrong, as I instantiated the newModel at the Setup method. And the method is running well if run the app.
Thoughts are appreciated.
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先尝试在调试中运行它以查看抛出异常的位置,
我猜你的 MyDatabase 有问题
First try running it in Debug to see where you are throwing the exception,
my guess is something is wrong with your MyDatabase