public void Should_Have_Validation_Error_When_Invalid_Command() { var notificationHandler = ServiceProvider.GetRequiredService <INotificationHandler>(); var command = AddTaskCommandMock.GetInvalidDto(); //call command.IsValid(); //assert Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidTaskName); }
public async Task Should_AddTasks() { //parameters var command = AddTaskCommandMock.GetValidDto(); //call var handler = GetTasksHandler(); var result = await handler.Handle(command, new System.Threading.CancellationToken()); //assert Assert.NotNull(result); Assert.False(_notificationHandler.HasNotification()); Assert.Equal(command.Name, result.Name); }
public async Task Should_Raise_Notification_When_Command_Is_Invalid() { //parameters var command = AddTaskCommandMock.GetInvalidDto(); //call var handler = GetTasksHandler(); var result = await handler.Handle(command, new System.Threading.CancellationToken()); //assert Assert.Null(result); Assert.True(_notificationHandler.HasNotification()); Assert.Contains(command.ValidationResult.Errors, e => e.CustomState is EntityError.InvalidTaskName); }