Remove test verifying orders
This commit is contained in:
parent
8d66f104f7
commit
be220e8bc2
|
|
@ -1,51 +0,0 @@
|
||||||
// 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;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
|
||||||
using Microsoft.AspNetCore.Mvc.ActionConstraints;
|
|
||||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|
||||||
{
|
|
||||||
// Tests that various MVC services have the correct order.
|
|
||||||
public class DefaultOrderTest : IClassFixture<MvcTestFixture<BasicWebSite.Startup>>
|
|
||||||
{
|
|
||||||
public DefaultOrderTest(MvcTestFixture<BasicWebSite.Startup> fixture)
|
|
||||||
{
|
|
||||||
Client = fixture.CreateDefaultClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpClient Client { get; }
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData(typeof(IActionDescriptorProvider), "Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider", -1000)]
|
|
||||||
[InlineData(typeof(IActionInvokerProvider), null, -1000)]
|
|
||||||
[InlineData(typeof(IApiDescriptionProvider), null, -1000)]
|
|
||||||
[InlineData(typeof(IFilterProvider), null, -1000)]
|
|
||||||
[InlineData(typeof(IActionConstraintProvider), null, -1000)]
|
|
||||||
public async Task ServiceOrder_GetOrder(Type serviceType, string actualType, int order)
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var url = "http://localhost/Order/GetServiceOrder?serviceType=" + serviceType.AssemblyQualifiedName;
|
|
||||||
|
|
||||||
if (actualType != null)
|
|
||||||
{
|
|
||||||
url += "&actualType=" + actualType;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var response = await Client.GetAsync(url);
|
|
||||||
var content = await response.Content.ReadAsStringAsync();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
||||||
Assert.Equal(order, int.Parse(content));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
// 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;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace BasicWebSite
|
|
||||||
{
|
|
||||||
public class OrderController : Controller
|
|
||||||
{
|
|
||||||
public int GetServiceOrder(string serviceType, string actualType)
|
|
||||||
{
|
|
||||||
var elementType = Type.GetType(serviceType);
|
|
||||||
|
|
||||||
var queryType = typeof(IEnumerable<>).MakeGenericType(elementType);
|
|
||||||
|
|
||||||
var services = (IEnumerable<object>)HttpContext?.RequestServices.GetService(queryType);
|
|
||||||
foreach (var service in services)
|
|
||||||
{
|
|
||||||
if (actualType != null && service.GetType().FullName == actualType)
|
|
||||||
{
|
|
||||||
var orderProperty = elementType.GetTypeInfo().GetDeclaredProperty("Order");
|
|
||||||
return (int)orderProperty.GetValue(service);
|
|
||||||
}
|
|
||||||
else if (actualType == null)
|
|
||||||
{
|
|
||||||
var orderProperty = elementType.GetProperty("Order");
|
|
||||||
return (int)orderProperty.GetValue(service);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue