Files
data
debian
docs
eglib
external
Lucene.Net.Light
Newtonsoft.Json
aspnetwebstack
packages
src
test
Microsoft.TestCommon
Microsoft.Web.Helpers.Test
Microsoft.Web.Http.Data.Test
Microsoft.Web.Mvc.Test
Microsoft.Web.WebPages.OAuth.Test
SPA.Test
System.Json.Test.Integration
System.Json.Test.Unit
System.Net.Http.Formatting.Test.Integration
System.Net.Http.Formatting.Test.Unit
System.Web.Helpers.Test
System.Web.Http.Integration.Test
System.Web.Http.SelfHost.Test
System.Web.Http.Test
Common
Controllers
Dispatcher
Filters
Hosting
HttpRouteTest.cs
Internal
Metadata
ModelBinding
Properties
Query
Routing
Services
Tracing
Util
Validation
ValueProviders
AuthorizeAttributeTest.cs
DictionaryExtensionsTest.cs
HttpRequestMessageExtensionsTest.cs
HttpResponseExceptionTest.cs
HttpResponseMessageExtensionsTest.cs
HttpRouteCollectionExtensionsTest.cs
HttpServerTest.cs
QueryableAttributeTest.cs
System.Web.Http.Test.csproj
packages.config
System.Web.Http.WebHost.Test
System.Web.Mvc.Test
System.Web.Razor.Test
System.Web.WebPages.Administration.Test
System.Web.WebPages.Deployment.Test
System.Web.WebPages.Razor.Test
System.Web.WebPages.Test
WebMatrix.Data.Test
WebMatrix.WebData.Test
Settings.StyleCop
tools
.gitattributes
.gitignore
License.txt
README.md
Runtime.msbuild
Runtime.sln
Runtime.xunit
Settings.StyleCop
build.cmd
binary-reference-assemblies
cecil
debian-snapshot
ikdasm
ikvm
referencesource
rx
ikvm-native
libgc
m4
man
mcs
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
ChangeLog.REMOVED.git-id
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h

41 lines
1.8 KiB
C#
Raw Normal View History

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Net.Http;
using System.Web.Http.Routing;
using Microsoft.TestCommon;
using Xunit.Extensions;
using Assert = Microsoft.TestCommon.AssertEx;
namespace System.Web.Http.Hosting
{
public class HttpRouteTest
{
[Theory]
[InlineData("{controller}/{id}", "/SelfHostServer", "http://localhost/SelfHostServer/Customer/999")]
[InlineData("{controller}/{id}", "", "http://localhost/Customer/999")]
[InlineData("{controller}", "", "http://localhost/")]
[InlineData("{controller}", "/SelfHostServer", "http://localhost/SelfHostServer")]
[InlineData("{controller}", "", "http://localhost")]
[InlineData("{controller}/{id}", "", "http://localhost/")]
[InlineData("{controller}/{id}", "/SelfHostServer", "http://localhost/SelfHostServer")]
[InlineData("{controller}/{id}", "", "http://localhost")]
public void GetRouteDataShouldMatch(string uriTemplate, string virtualPathRoot, string requestUri)
{
HttpRoute route = new HttpRoute(uriTemplate);
route.Defaults.Add("controller", "Customer");
route.Defaults.Add("id", "999");
HttpRequestMessage request = new HttpRequestMessage();
request.RequestUri = new Uri(requestUri);
IHttpRouteData data = route.GetRouteData(virtualPathRoot, request);
// Assert
Assert.NotNull(data);
IDictionary<string, object> expectedResult = new Dictionary<string, object>();
expectedResult["controller"] = "Customer";
expectedResult["id"] = "999";
Assert.Equal(expectedResult, data.Values, new DictionaryEqualityComparer());
}
}
}