Commit Graph

8 Commits

Author SHA1 Message Date
Doug Bunting 83a559c28c Add `ModelValidationNode`s consistently
- #2633
- do not leave `ModelBindingResult.ValidationNode` as `null` when we hit the `null` `RawValue` special case
 - move two bits of code together to make the special case more obvious
- add `ModelValidationNode` (that suppresses validation) when `HttpRequestMessageModelBinder` is successful
 - also suppress validation of `HttpRequestMEssage` properties
- suppress validation in `CancellationTokenModelBinder`, `FormCollectionModelBinder`, `FormCollectionModelBinder`
- do not create a `ModelValidationNode` when validation fails in `TypeConverterModelBinder`

nits:
- improve some doc comments
- add a quick `HttpRequestMessageModelBinderTest`
2015-08-11 08:30:29 -07:00
Doug Bunting 715a0b6021 Add `ModelState` entries for greedy and type-matching model binders
- part II of II for #2445
- `FormCollectionModelBinder` is an exception because container is not user-provided
 - no `ModelState` entry added
- enable tests that #2445 was blocking
 - fix these and other tests expecting different `ModelState` entries
- simplify logic in `FormFileModelBinder`

`ValueProviderResult`
- remove `protected` setters and parameterless constructor
 - no scenario for their use in subclasses; however `ConvertTo()` remains `virtual`
- add single-parameter constructor
 - use in most of the greedy and type-matching model binders
- add doc comments throughout class

nits:
- use new `ValueProviderResult` constructor in many existing tests
- `""` -> `string.Empty` and `vpr` -> `valueProviderResult` in `ValueProviderResultTest`
- improve some test names in `BodyValidationIntegrationTests`
- do not check `Message` of a Json.NET `Exception`
2015-06-23 22:34:55 -07:00
Doug Bunting 26795bd4b5 Correct test expectations
- use valid `multipart/form-data` content type; include a `boundary`
- correct expectations of `FormCollection` model binder's operation
 - restore tests actually skipped for either of the above reasons
- add more tests with `ModelBindingResult.Model==null` and both `IsModelSet` values

#### Remove test references to Won't Fix bug #2473
- restore #2473 tests; update test expectations
- expect `null` composite results whenever binding fails

#### Restore test skipped due to "#2646"
- that issue does not exist; was likely #2466 or similar fixed bug

#### Rename model binding tests that still mention ReturnsFalse or ReturnsTrue

#### Minor src changes
- remove unused variable and unnecessary nesting in `DefaultControllerActionArgumentBinder`
- remove dangling mention of `[DefaultValue]` in `ComplexModelDtoModelBinder`

#### nits:
- remove empty delegates from some `GetOperationBindingContext` calls; `null` fine
- do some `using` cleanup
- combine two test methods in `KeyValuePairModelBinderTest`
- name a few more arguments
2015-06-01 12:15:39 -07:00
Harsh Gupta 88ac4b94e4 Fixing #2466, #2446.
The assumption is ModelState should have entries if
1. An error is explicitly added by a model binder.
2. There is validation error reported while validating the model.
3. There is value bound by the model binder.

With this change there should be no extra entry other than for the cases mentioned above.

Also enabling the integration test cases.
2015-05-15 12:27:41 -07:00
Chris R bd03142dab React to Http namespace changes. 2015-05-07 15:19:10 -07:00
Chris R 7f737246b1 React to QueryString API changes. 2015-05-06 15:20:40 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
Harsh Gupta b5b37265e1 Simple ModelBinders and Simple ModelBinder Poco - 1
Covers simple scenario for each model binder.
Covers scenarios mixing a POCO model binder -> Simple Model binder.

This contains tests for
HeaderModel
ServicesModelBinder
CancellationTokenModelBinder
ByteArrayModelBinder
FormFileModelBinder

Part 2 Will contain similar tests for
FormCollectionModelBinder
BinderTypeBasedModelBinder
TypeConverterModelBinder
TypeMatchModelBinder
Any leftovers for BodyModelBinder
2015-04-28 14:13:36 -07:00