79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc.Internal;
|
|
using Microsoft.AspNetCore.Routing;
|
|
using Newtonsoft.Json;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|
{
|
|
public class RoutingTests : RoutingTestsBase<RoutingWebSite.Startup>
|
|
{
|
|
public RoutingTests(MvcTestFixture<RoutingWebSite.Startup> fixture)
|
|
: base(fixture)
|
|
{
|
|
}
|
|
|
|
[Fact]
|
|
public async override Task HasEndpointMatch()
|
|
{
|
|
// Arrange & Act
|
|
var response = await Client.GetAsync("http://localhost/Routing/HasEndpointMatch");
|
|
|
|
// Assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
|
|
var body = await response.Content.ReadAsStringAsync();
|
|
var result = JsonConvert.DeserializeObject<bool>(body);
|
|
|
|
Assert.False(result);
|
|
}
|
|
|
|
[Fact]
|
|
public async override Task RouteData_Routers_ConventionalRoute()
|
|
{
|
|
// Arrange & Act
|
|
var response = await Client.GetAsync("http://localhost/RouteData/Conventional");
|
|
|
|
// Assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
|
|
var body = await response.Content.ReadAsStringAsync();
|
|
var result = JsonConvert.DeserializeObject<ResultData>(body);
|
|
|
|
Assert.Equal(
|
|
new string[]
|
|
{
|
|
typeof(RouteCollection).FullName,
|
|
typeof(Route).FullName,
|
|
typeof(MvcRouteHandler).FullName,
|
|
},
|
|
result.Routers);
|
|
}
|
|
|
|
[Fact]
|
|
public async override Task RouteData_Routers_AttributeRoute()
|
|
{
|
|
// Arrange & Act
|
|
var response = await Client.GetAsync("http://localhost/RouteData/Attribute");
|
|
|
|
// Assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
|
|
var body = await response.Content.ReadAsStringAsync();
|
|
var result = JsonConvert.DeserializeObject<ResultData>(body);
|
|
|
|
Assert.Equal(new string[]
|
|
{
|
|
typeof(RouteCollection).FullName,
|
|
typeof(AttributeRoute).FullName,
|
|
typeof(MvcAttributeRouteHandler).FullName,
|
|
},
|
|
result.Routers);
|
|
}
|
|
}
|
|
}
|