【发布时间】:2020-07-16 21:08:15
【问题描述】:
我正在使用 CQRS 编写应用程序。我有我的命令和我的 commandHandler。我确实测试了我的命令处理程序。但是......你应该推荐测试命令吗?最好的策略是什么?我应该测试所有的验证可能性吗?小伙伴们怎么样?
using System;
using Flunt.Notifications;
using Flunt.Validations;
using Todo.Domain.Commands.Contracts;
namespace Todo.Domain.Commands
{
public class CreateTodoCommand : Notifiable, ICommand
{
public CreateTodoCommand() { }
public CreateTodoCommand(string title, string user, DateTime date)
{
Title = title;
User = user;
Date = date;
}
public string Title { get; set; }
public string User { get; set; }
public DateTime Date { get; set; }
public void Validate()
{
AddNotifications(
new Contract()
.Requires()
.HasMinLen(Title, 3, "Title", "Please, describe better your task!")
.HasMinLen(User, 6, "User", "Invalid User!")
);
}
}
}
【问题讨论】:
标签: asp.net-mvc asp.net-core cqrs