Commit Graph

18 Commits

Author SHA1 Message Date
Ryan Nowak 6875ee55d3 Remove Magic Link Generation
This change resolves #3512 and #3636 by removing 'magic' link generation
and adding an extension method to add routes to areas correctly using the new
pattern. This is pretty much exactly the same as how MapWebApiRoute works.

For site authors, we recommend adding area-specific routes in a way that
includes a default AND constraint for the area. Put your most specific
(for link generation) routes FIRST.

Ex:

  routes.MapRoute(
      "Admin/{controller}/{action}/{id?}",
      defaults: new { area = "Admin" },
      constraints: new { area = "Admin" });

The bulk of the changes here are to tests that unwittingly relied on the
old behavior.
2015-11-30 11:24:23 -08:00
Doug Bunting cf30bb730f PR comments and some smallish cleanup
- `IRazorViewEngine.MakePathAbsolute()` -> `GetAbsolutePath()`
- set `IsPartial` on all `IRazorPage` instances
- improve consistency of methods in `HtmlHelperPartialExtensions`
  - a couple unnecessarily passed `htmlHelper.ViewData`
  - add missing tests of these extension methods
- restore parameter checks in `CompositeViewEngine`
- reduce `List<string>` and remove enumerator allocations in `CompositeViewEngine`

nits:
- correct a few comments
- use `<seealso/>`
2015-11-18 15:59:28 -08:00
Doug Bunting d03a851ab3 Use `MvcTextFixture` as much as possible
- #3066
  - reduce `TestServer` -> `PhysicalFileProvider` -> `FileSystemWatcher` count enough to run with Core CLR on Linux
- remove use of `HttpClient.DefaultRequestHeaders`; any client change affects other tests
- remove use of `RequestBuilder` class; creates a per-test `HttpClient` and requires the `TestServer`
- updated a few expectations because `CommonTestEncoder` does JavaScript a bit differently
  - "JavaScriptEncode[[...]]" -> "JavaScriptStringEncode[[...]]"
- side benefit: xUnit reports functional tests execute for only ~12.4s; was >30s before this change

Infrastructure: Enhance `MvcTestFixture`
- handle `ConfigureServices()` methods that are not `void`
- handle `Configure(IApplicationBuilder, ILoggerFactory)`
- ensure server is initialized with consistent `CurrentCulture` and `CurrentUICulture`
- add `FilteredDefaultAssemblyProviderFixture<TStartup>` and `MvcEncodedTestFixture<TStartup>`
  - add `MvcTextFixture.AddAdditionalServices()` extension point supporting these

- do not expose the `TestServer`; an anti-pattern for tests to manipulate the server
- update class names to match containing files
- use existing `TestApplicationEnvironment`
  - apply some `MvcTestFixture` improvements to the shared `TestApplicationEnvironment` class
- remove unused methods from `TestHelper`

nits:
- touched-up some leftover `_app` &c declarations to be more explicit and minimize `using`s
- moved statements into correct sections of methods in `RoutingTests`
- removed `TestLoggerFactory` and related classes from `TagHelperSampleTest`
2015-09-15 10:18:27 -07:00
sornaks 68523a3550 Fixing tests in Mono.
- Disabling tests which have corresponding bugs in mono.
- Fixing a few tests which do not handle *nix file system.
- Updating Travis configuration to use mono's alpha bits.
- Introducing PlatformNormalizer to normalize content across multiple platforms.
2015-07-02 17:24:14 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
ianhong 21031a3aa8 Add sample and functional test for custom inline constraints 2015-04-17 08:42:20 -07:00
Hao Kung 4b5dd199ca React to hosting changes 2015-03-19 11:07:25 -07:00
Doug Bunting cc7b319cb7 Remove use of `ServiceDescriber` in MVC and cleanup related hacks
- see issues aspnet/DependencyInjection#193 and #1612
- use `TryAdd()` in `MvcServices` for the `IAssemblyProvider`

Move `ApplicationBasePath` handling into `RazorPreCompileModule`
- restores view precompilation in functional tests of sample sites
- if we need this, others will as well
- override `IApplicationEnvironment` but get folder from `ProjectContext`
 - also remove remaining `IServiceProvider` implementations in this code

test fixes:
- simplify `IApplicationEnvironment` override
- move override logic into `TestHelper.CreateServer()` methods
- remove `LoggerFactory` setup
 - does not seem to require special-casing
- remove unused `ITestConfigurationProvider` / `TestConfigurationProvider`
- remove `TestAssemblyProvider` classes
 - no longer required
- remove `ReplaceCallContextServiceLocationService` test helper
 - change MVC sample to fully-qualify config.json path
  - avoids `ReplaceCallContextServiceLocationService` need in `MvcSampleTests`
 - no longer required for other tests

nit: remove unused `_serviceProvider` and constructor overload in `RazorPreCompiler`
2015-03-10 22:25:42 -07:00
Doug Bunting 89fd1abc58 Nit: Clean up duplicate tests
- lead to errors during test discovery in VS
2015-01-13 12:49:26 -08:00
Ryan Nowak 6390bad0d3 Adding a pattern for returning 'unhandled' exception information via
middleware.

This should be used where posssible instead of throwing an exception and
catching in a test, as that only works in memory.
2014-12-15 16:29:08 -08:00
Mugdha Kulkarni ba8cf3ca46 Changed to use OptionalRouteConstraint created by Routing to use for inline optional parameters in attribute routing. Also added tests for inline parameters. 2014-12-04 11:00:48 -08:00
Ryan Nowak e54bf866e0 Simplifying InlineConstraints tests
Right now these use a commandline adapter to inject some data into the
tests, but it's really not needed. Instead, these routes use a prefix to
ensure that the scenario under test is isolated.
2014-11-21 11:28:44 -08:00
Hao Kung d9893b260a React to fallback changes 2014-11-20 17:43:55 -08:00
Stephen Halter a21ed4bc51 Replace calls to GetService<T> with GetRequiredService<T>
Even though GetService<T> still exists, GetRequiredService<T> preserves
the old behavior of throwing for missing services.
2014-10-16 14:51:41 -07:00
Chris Ross 85ad1aeb96 Handle IBuilder rename to IApplicationBuilder. 2014-09-10 14:12:08 -07:00
Pranav K b8692c2c21 Updating FunctionalTests to use HttpClient abstractions 2014-09-01 11:16:54 -07:00
harshgMSFT 08b64a2a4a InlineConstraint Functional Test, removing the dependency on a physical file. 2014-06-18 13:42:33 -07:00
harshgMSFT 10285d7d39 This additional constraint enables adding a route to the template (and potentially to the UseMvc method) without actually implementing the actual artifact.
For example without adding an area to a controller, a route can still be added to the template.
- Also added functional tests.
2014-06-16 11:24:22 -07:00