0
我已經加入數據標註爲模型,發現代碼,單元測試數據註解
public class DownloadInfo
{
[Required]
public string Name { get; set; }
[Required]
[Email]
public string Email { get; set; }
}
,我首先要給無效的電子郵件ID喜歡下面寫這個數據的註解單元測試。
[Test]
public void InvalidTestPost()
{
TestControllerBuilder builder = new TestControllerBuilder();
DownloadController downloadController = builder.CreateController<DownloadController>();
DownloadInfo downloadInfo = new DownloadInfo();
downloadInfo.Email= "some invaild email";
Assert.IsTrue(!downloadController.ModelState.IsValid);
}
我該如何單元測試數據註釋?
Regards, Karthik。