【问题标题】:mvc NUNIT System.NotImplementedException : The Method or Operation is not Implementedmvc NUNIT System.NotImplementedException:方法或操作未实现
【发布时间】:2011-08-09 18:58:46
【问题描述】:

我的 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();
    }
}

我在 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 : 方法或操作未实现。

所以我不确定出了什么问题,因为我在 Setup 方法中实例化了 newModel。如果运行应用程序,该方法运行良好。 感谢您的想法。

谢谢!!

【问题讨论】:

  • 尝试共享您为 NotImplementedException 获得的堆栈跟踪。
  • 抱歉,我如何共享堆栈跟踪?我是 C# 编程新手,如果我有点慢,请原谅我:)

标签: asp.net-mvc unit-testing nunit vs-unit-testing-framework


【解决方案1】:

首先尝试在 Debug 中运行它,看看你在哪里抛出异常, 我的猜测是您的 MyDatabase 有问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-20
    • 1970-01-01
    • 2015-05-29
    • 2016-04-06
    • 2019-03-15
    • 1970-01-01
    • 1970-01-01
    • 2021-03-01
    相关资源
    最近更新 更多