我有一个简单的页面模型PizzaModel
:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace starting_app.Pages
{
public class PizzaModel : PageModel
{
public string Customer {get; set;}
public int Total {get; set;}
public string SomeProperty {get; set;}
public void OnGet()
{
}
}
}
我正在使用NUnit
框架来测试某些属性:
using System;
using NUnit.Framework;
using blank_workspace.Pages;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
namespace starting_app.UnitTests
{
[TestFixture]
public class Tests
{
[Test]
public void PizzaModel_Asserts_Customer_Property()
{
PizzaModel pm = new PizzaModel();
Assert.That(pm, Has.Property("Customer"));
}
}
}
这是正确的格式吗?
我目前遇到另一种错误:
找不到类型或名称空间名称“ NUnit”(您是否缺少using指令或程序集引用?)
但是我正在尝试使我的语法正确。