-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation not tested. #27
Comments
I had read that. I'm not making a comment on the handlers, more on the how to test the validation in the handlers. I think there are two alternatives; add some controller tests to ensure binding validation runs or modify
if (!ModelState.IsValid) return this.BadRequest(ModelState); Edit: That's probably taken care of by the |
So in real life, not this contrived application, we use a MediatR pipeline
to execute command/domain validation. The request validation is just
attributes, declarative, and therefore tests don't really add much value
imo.
…On Wed, Feb 21, 2018 at 12:52 PM, Nathan Brown ***@***.***> wrote:
I had read that. I'm not making a comment on the handlers, more on the how
to test the validation in the handlers.
I think there are two alternatives; add some controller tests to ensure
binding validation runs or modify SliceFixture.SendAsync to also run the
validation.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGYMhHvC8w8rODSr2a6pz0kPahqF45Kks5tXGXagaJpZM4SOC_R>
.
|
There are tests for each of the commands, but none of them end up exercising the validation on the commands. That is the FluentValidation or the ComponentModel.DataAnnotation attributes that are on some command properties.
For example, if the following test was added to the
ContosoUniversityCore.IntegrationTests.Features.Department.CreateTest
class:The test would fail because the command's validator rules are not exercised. Specifically this one:
It seems they are only evaluated on model binding, but no tests exercise that path as it would require spinning up an in-memory ASP.Net server.
How do you normally test the validations? It seems that command validation testing is a central part of the tests that should be in place.
The text was updated successfully, but these errors were encountered: