Commit Graph

478 Commits

Author SHA1 Message Date
Ryan Nowak 105c99cbf2 Fix #1370 - Always use the provided formatter in JsonResult
The change here is to always use the provided formatter, instead of using
it as a fallback. This is much less surprising for users.

There are some other subtle changes here and cleanup of the tests, as well
as documentation additions.

The primary change is that we still want to run 'select' on a formatter
even if it's the only one. This allows us to choose a content type based
on the accept header.

In the case of a user-provided formatter, we'll try to honor the best
possible combination of Accept and specified ContentTypes (specified
ContentTypes win if there's a conflict). If nothing works, we'll still run
the user-provided formatter and let it decide what to do.

In the case of the default (formatters from options) we do conneg, and if
there's a conflict, fall back to a global (from services)
JsonOutputFormatter - we let it decide what to do.

This should leave us with a defined and tested behavior for all cases.
2014-10-31 14:30:31 -07:00
sornaks d178200795 Adding functional tests for Filters. 2014-10-31 08:36:31 -07:00
Pranav K 3aaeebd9c5 Revert "Revert "Added a functional test for view precompilation""
This reverts commit 6b2ab32885.
2014-10-30 14:38:44 -07:00
Doug Bunting 5420b9d382 More `ViewDataDictionary` tests
- separate and extend `ViewDataDictionary<TModel>` tests
2014-10-29 19:19:09 -07:00
Doug Bunting c89bca5924 Adjust tests to handle new `ViewDataDictionary` invariants
- ensure `ViewDataDictionary` constructors are not passed a `null` or
  `Mock.Of<IModelMetadataProvider>()` instance
 - `ViewDataDictionary` constructors always use the `IModelMetadataProvider`
- `viewData.ModelMetadata` now never `null`
- `ViewDataDictionary<int>.Model` no longer throws if read before it's written
- `ViewDataDictionary.ModelMetadata` now copied to new instances in fewer cases
 - e.g. don't use unusual `object` datatype with customized `ModelMetadata`
2014-10-29 19:18:59 -07:00
Ryan Nowak 83187945d1 Fix for #1052 - ViewComponents should support fully qualified names
This change adds the concept of a full-name to viewcomponents. View
components can be invoked using either the short name or long name. If the
provided string contains a '.' character, then it will be compared against
full names, otherwise it will be matched against short names only.

The short name is used for view lookups.

If the name is explicitly set via ViewComponent attribute, then the full
name is the name provided. The short name is the portion of the name after
the last '.'. If there are no dots, then the short name and full name are
the same.

If the name is not set explicitly, then it is inferred from the Type and
namespace name. The short name is the Type name, minus the 'ViewComponent'
suffix (if present). The full name is the namespace of the defining class,
plus the short name.
2014-10-29 17:34:01 -07:00
jacalvar 6b2ab32885 Revert "Added a functional test for view precompilation"
This reverts commit 310feeb826.
2014-10-28 19:14:50 -07:00
jacalvar 310feeb826 Added a functional test for view precompilation 2014-10-28 18:38:15 -07:00
Ryan Nowak 305dd87b9b Fix for #1442 - Find better names for ApiExplorerProperties
Taking the suggestion here to move these to a sub-object. This is future
proof in the event that we need to capture more data for ApiExplorer, and
reads better.
2014-10-28 13:03:19 -07:00
Ryan Nowak 46897037e9 TODO removal part 1 - ActionExecutorTests 2014-10-28 12:54:14 -07:00
Ryan Nowak 9a77c2bc1e Fix for #1448 - ViewComponents must be public top-level classes
ViewComponents and Controllers now follow the same rules exactly for what
types of classes they can be.

Also corrected a bug in a test for controllers. Closed-generic types can
be controllers, the test was wrong.
2014-10-28 12:36:07 -07:00
Pranav K 6c4462a76f * Porting Hidden and HiddenFor unit tests
Partial fix to #453
2014-10-27 17:54:56 -07:00
Doug Bunting 1f670bf3a7 Merge branch 'release' into dev 2014-10-27 16:43:02 -07:00
Doug Bunting cfcb1f2e2f Add more unit tests of `ViewDataDictionary` copy constructors 2014-10-27 16:26:04 -07:00
Pranav K e0116bab30 Modifying ArgumentNullOrEmpty message to be consistent with Mvc 5 \
testing code.
2014-10-27 15:07:53 -07:00
N. Taylor Mullen 7934c432c8 React to case insensitive TagHelperOutput.Attributes.
- Cleaned up some existing bad code that worked around case sensitive TagHelperOutput.Attributes.
- Modified MergeAttributes to be case insensitive when it comes to merging class attributes.
- Added a test to verify the new MergeAttribute case insensitive class merging.

aspnet/Razor#186
2014-10-26 13:32:11 -07:00
N. Taylor Mullen 09af7bb77b Change TagBuilder Attributes and HTML Helper dependencies to be case insensitive.
- This involved adding the StringComparer.OrdinalIgnoreCase comparer to the TagBuilder's Attributes dictionary.
- Added tests to validate that all methods that made use of TagBuilder.Attributes abide by the new ignore case mechanic.
- Added two sets of tests to validate the new functionality of Object => Dictionary HTML helper tests.
- Modified a functional test that utilizes HTML Helpers to provide same attribute-different case objects.
- Fixed existing HTML helper tests to account for new ordering of attrbutes (dictionary no longer adds key value pairs, it sets them).

#1328
2014-10-26 13:15:09 -07:00
Ryan Nowak 0a3ad09466 Rename GlobalModel -> ApplicationModel
This also comes with a rename of the namespace
Microsoft.AspNet.Mvc.ApplicationModel to
Microsoft.AspNet.Mvc.ApplicationModels.

Also tuned up some parameter and variable names for increased
understandability.
2014-10-23 16:03:55 -07:00
Ryan Nowak 7ae5e66ccd Refactoring the ControllerActionDescriptorProvider 2014-10-23 12:25:25 -07:00
Pranav K 756f8be49c CompositeValueProvider.GetKeysFromPrefixAsync throws null if provider is not an
IEnumerableValueProvider

Fixes #1419
2014-10-23 11:05:06 -07:00
Pranav K 26cd8df577 Adding functional tests to verify round tripping of names generated by
HtmlHelpers
2014-10-23 10:12:02 -07:00
sornaks 1dd1652dcf Issue #220 - Flags enum does not bind
Fix - After TypeConverter support this works. Adding tests for the same.
2014-10-22 13:55:28 -07:00
Pranav K 78bda87730 Replacing ViewResultBase with ViewExecutor 2014-10-22 08:47:22 -07:00
Pranav K 79ad19f8bd Porting CheckBox and CheckBoxFor unit tests
Partial fix to #453
2014-10-20 11:12:10 -07:00
Doug Bunting d31e107619 Add `SelectTagHelper` tests 2014-10-19 22:29:50 -07:00
Ryan Nowak 557974b948 Removing BodyParameterInfo and ParameterBindingInfo
These have been superceded by the BinderMetadata property on
ParameterDescriptor.
2014-10-17 20:47:20 -07:00
Ryan Nowak 61f218c8e4 Renaming IBinderMarker and friends to some more descriptive names. 2014-10-17 20:32:03 -07:00
Harsh Gupta d1c0213a10 Adding PropertyFilter instead of depending on model metadata to concatenate Metadata for parameter/property and type metadata 2014-10-17 20:07:33 -07:00
Ryan Nowak 77c4391e47 Fix for #1401 - Change namespace of HttpResponseException 2014-10-17 18:43:06 -07:00
Pranav K bd82e584f0 Porting over unit tests for ViewDataDictionary.Eval
Partial fix for #453
2014-10-17 17:27:05 -07:00
Ryan Nowak df8f84b772 Fix #1287 - Port WebAPI parameter binding behavior
This change modifies the default parameter binding behavior for an
ApiController to use the WebAPI rules.

'simple types' default to use route data or query string
'complex types' default to use the body (formatters)

Adds ModelBindingAttribute to enabled model binding
2014-10-17 16:51:48 -07:00
sornaks 5b1bcb6079 Issue #1214: Cannot pass a int parameter to the views from ViewComponent.
Fix: Checking if the model is not null in the Copy constructor of ViewDataDictionary.
2014-10-17 16:40:25 -07:00
Harsh Gupta 75405e3b76 Adding support for bind attribute. 2014-10-17 16:24:28 -07:00
Doug Bunting dd5da33a62 Sanitize "id" attributes for HTML 4.0.1
- #704 part 2 of 2
- change `@Html.Id()` to sanitize return value; was identical to `@Html.Name()`

Copied `TagBuilder.CreateSanitizedId()` and `TagBuilder.Html401IdUtil` from MVC 5.2
- except this `CreateSanitizedId()` returns a valid identifier if first `char` is not a letter
 - e.g. "[0].Name"

nits:
- expand variable names, use lots of `var`, put `public` members first
- add doc comments for `CreateSanitizedId()`

Note users will be able to apply different sanitization once we fix #1188.
2014-10-17 16:12:45 -07:00
jacalvar 98d749d03c [Fixes #1389] Can't bind complex type data from route parameters.
Changed DictionaryBasedValueProvider to do a prefix check instead of just checking if the underlying
dictionary contains the key.
2014-10-17 15:32:21 -07:00
Pranav K 66f626b828 Remove unnecessary references from project.json 2014-10-17 14:26:58 -07:00
Pranav K 5119d16b64 ViewComponent.Invoke() should be able to invoke views
Fixes #285
2014-10-17 12:23:18 -07:00
Pranav K b8d30f29c6 Add IsPartial property to IRazorPage
Fixes #1002
2014-10-17 10:52:39 -07:00
Doug Bunting 012e03e5d0 Add `InputTagHelper`
- also make `TagHelperOutputExtensions.MergeAttributes()` case-insensitive

nits:
- deliniate attribute names in all resource strings
- update validation messages in TagHelperSample.Web
2014-10-16 23:34:10 -07:00
N. Taylor Mullen f8f08f0903 Fix tests and changed TagHelper activates property accessors.
- Changed TagHelper property accessors from private to protected internal.
- Changed throw tests to be shorter.
- Changed reflection setting to now use the internal accessibility of the TagHelpers
- Removed activator to just use internal accessibility of TagHelpers.
- Changed new StringWriter() instances where we didn't need the StringWriter to be TextWriter.Null
2014-10-16 22:39:44 -07:00
N. Taylor Mullen f8b0249918 Add Label TagHelper.
- Validated label TagHelper functionality.

#1249
2014-10-16 21:13:08 -07:00
NTaylorMullen 9c07055ac7 Add ValidationSummaryTagHelper.
- Tested ValidationSummaryTagHelper behavior.
- Updated sample to utilize new ValidationSummaryTagHelper format.

#1251
2014-10-16 21:13:05 -07:00
NTaylorMullen 2729cdc9b7 Add ValidationMessageTagHelper.
- Added tests to validate ValidationMessageTagHelper functionality.

#1250
2014-10-16 21:12:53 -07:00
NTaylorMullen 57d1c542db Add AnchorTagHelper.
- Added a TagHelper that targets the <a> tag and allows users to do the equivalent of Html.ActionLink or Html.RouteLink.
- Added tests to validate AnchorTagHelper functionality.

#1247
2014-10-16 21:12:49 -07:00
N. Taylor Mullen 4c98c8fcb9 Add FormTagHelper.
- Added the FormTagHelper.
- Utilized the IHtmlGenerator to share base functionality with the HTMLHelper counterparts.
- Added tests to validate FormTagHelper functionality.

#1246
2014-10-16 21:12:46 -07:00
N. Taylor Mullen 63f8f7de6d Add extensions for TagHelperOutput to copy and merge from TagBuilder.
- Added tests to validate functionality of all TagHelperOutputExtension methods.

#1319
2014-10-16 21:12:42 -07:00
NTaylorMullen 20cc294c70 Reacted to options and hosting changes after rebase. 2014-10-16 21:12:38 -07:00
Doug Bunting 3b7b0f867d Update `HtmlHelper` to use `IHtmlGenerator`
- make a few more methods available as `internal static` in `DefaultHtmlGenerator`
 - remove `IHtmlGenerator.GenerateOption()`; now `internal static`

nits:
- add `IHtmlGenerator.IdAttributeDotReplacement`
- move `DefaultHtmlGenerator.IdAttributeDotReplacement` after constructor
- move `HtmlHelper.ActionLink()` below static methods
- move newly-`internal` methods together in `DefaultHtmlGenerator`
- correct placement of `DefaultHtmlGenerator.GetValidationAttributes()` comment
2014-10-16 21:12:34 -07:00
Doug Bunting ba8b3d14a4 Add tests of `TextAreaTagHelper`
- new Microsoft.AspNet.Mvc.TagHelpers.Test project
- bit of test infrastructure -- `TestableHtmlGenerator`
 - short-curcuits validation attribute and AntiForgery additions
 - should help when testing all MVC tag helpers
2014-10-16 21:09:11 -07:00
Ryan Nowak 9fadcf74ca Fix for item #1278 - Add WebAPI ActionResult types and helper methods on
ApiController

Ports all of the WebAPI action result types.
2014-10-16 19:33:49 -07:00